json 1.6.6-java → 1.6.7-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of json might be problematic. Click here for more details.

@@ -1,4 +1,5 @@
1
1
  require 'json/version'
2
+ require 'json/light_object'
2
3
 
3
4
  module JSON
4
5
  class << self
Binary file
Binary file
@@ -0,0 +1,45 @@
1
+ require 'ostruct'
2
+
3
+ module JSON
4
+ class LightObject < OpenStruct
5
+ class << self
6
+ alias [] new
7
+
8
+ def json_create(data)
9
+ data = data.dup
10
+ data.delete JSON.create_id
11
+ self[data]
12
+ end
13
+ end
14
+
15
+ def to_hash
16
+ table
17
+ end
18
+
19
+ def [](name)
20
+ to_hash[name.to_sym]
21
+ end
22
+
23
+ def []=(name, value)
24
+ modifiable[name.to_sym] = value
25
+ end
26
+
27
+ def |(other)
28
+ self.class[other.to_hash.merge(to_hash)]
29
+ end
30
+
31
+ def as_json(*)
32
+ to_hash | { JSON.create_id => self.class.name }
33
+ end
34
+
35
+ def to_json(*a)
36
+ as_json.to_json(*a)
37
+ end
38
+
39
+ def method_missing(*a, &b)
40
+ to_hash.__send__(*a, &b)
41
+ rescue NoMethodError
42
+ super
43
+ end
44
+ end
45
+ end
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.6.6'
3
+ VERSION = '1.6.7'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -21,7 +21,7 @@ unless Array.method_defined?(:permutation)
21
21
  end
22
22
  end
23
23
 
24
- class TC_JSON < Test::Unit::TestCase
24
+ class TestJSON < Test::Unit::TestCase
25
25
  include JSON
26
26
 
27
27
  def setup
@@ -109,6 +109,8 @@ class TC_JSON < Test::Unit::TestCase
109
109
  def test_parse_json_primitive_values
110
110
  assert_raise(JSON::ParserError) { JSON.parse('') }
111
111
  assert_raise(JSON::ParserError) { JSON.parse('', :quirks_mode => true) }
112
+ assert_raise(TypeError) { JSON::Parser.new(nil).parse }
113
+ assert_raise(TypeError) { JSON::Parser.new(nil, :quirks_mode => true).parse }
112
114
  assert_raise(TypeError) { JSON.parse(nil) }
113
115
  assert_raise(TypeError) { JSON.parse(nil, :quirks_mode => true) }
114
116
  assert_raise(JSON::ParserError) { JSON.parse(' /* foo */ ') }
@@ -314,6 +316,16 @@ class TC_JSON < Test::Unit::TestCase
314
316
  assert res.item_set?
315
317
  end
316
318
 
319
+ def test_parse_light_object
320
+ res = parse('{"foo":"bar", "baz":{}}', :object_class => JSON::LightObject)
321
+ assert_equal(JSON::LightObject, res.class)
322
+ assert_equal "bar", res.foo
323
+ assert_equal "bar", res["foo"]
324
+ assert_equal "bar", res[:foo]
325
+ assert_equal "bar", res.to_hash[:foo]
326
+ assert_equal(JSON::LightObject, res.baz.class)
327
+ end
328
+
317
329
  def test_generate_core_subclasses_with_new_to_json
318
330
  obj = SubHash2["foo" => SubHash2["bar" => true]]
319
331
  obj_json = JSON(obj)
@@ -10,7 +10,7 @@ require 'json/add/bigdecimal'
10
10
  require 'json/add/ostruct'
11
11
  require 'date'
12
12
 
13
- class TC_JSONAddition < Test::Unit::TestCase
13
+ class TestJSONAddition < Test::Unit::TestCase
14
14
  include JSON
15
15
 
16
16
  class A
@@ -64,7 +64,7 @@ class TC_JSONAddition < Test::Unit::TestCase
64
64
 
65
65
  def to_json(*args)
66
66
  {
67
- 'json_class' => 'TC_JSONAddition::Nix',
67
+ 'json_class' => 'TestJSONAddition::Nix',
68
68
  }.to_json(*args)
69
69
  end
70
70
  end
@@ -88,7 +88,7 @@ class TC_JSONAddition < Test::Unit::TestCase
88
88
  a_hash = JSON.parse(json, :create_additions => false)
89
89
  assert_kind_of Hash, a_hash
90
90
  assert_equal(
91
- {"args"=>[666], "json_class"=>"TC_JSONAddition::A"}.sort_by { |k,| k },
91
+ {"args"=>[666], "json_class"=>"TestJSONAddition::A"}.sort_by { |k,| k },
92
92
  a_hash.sort_by { |k,| k }
93
93
  )
94
94
  end
@@ -97,7 +97,7 @@ class TC_JSONAddition < Test::Unit::TestCase
97
97
  b = B.new
98
98
  assert !B.json_creatable?
99
99
  json = generate(b)
100
- assert_equal({ "json_class"=>"TC_JSONAddition::B" }, JSON.parse(json))
100
+ assert_equal({ "json_class"=>"TestJSONAddition::B" }, JSON.parse(json))
101
101
  end
102
102
 
103
103
  def test_extended_json_fail2
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONEncoding < Test::Unit::TestCase
7
+ class TestJSONEncoding < Test::Unit::TestCase
8
8
  include JSON
9
9
 
10
10
  def setup
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONFixtures < Test::Unit::TestCase
7
+ class TestJSONFixtures < Test::Unit::TestCase
8
8
  def setup
9
9
  fixtures = File.join(File.dirname(__FILE__), 'fixtures/*.json')
10
10
  passed, failed = Dir[fixtures].partition { |f| f['pass'] }
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONGenerate < Test::Unit::TestCase
7
+ class TestJSONGenerate < Test::Unit::TestCase
8
8
  include JSON
9
9
 
10
10
  def setup
@@ -6,7 +6,7 @@ require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
  require 'stringio'
7
7
  require 'time'
8
8
 
9
- class TestJsonStringMatching < Test::Unit::TestCase
9
+ class TestJSONStringMatching < Test::Unit::TestCase
10
10
  include JSON
11
11
 
12
12
  class TestTime < ::Time
@@ -4,7 +4,7 @@
4
4
  require 'test/unit'
5
5
  require File.join(File.dirname(__FILE__), 'setup_variant')
6
6
 
7
- class TC_JSONUnicode < Test::Unit::TestCase
7
+ class TestJSONUnicode < Test::Unit::TestCase
8
8
  include JSON
9
9
 
10
10
  def test_unicode
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.6.6
5
+ version: 1.6.7
6
6
  platform: java
7
7
  authors:
8
8
  - Daniel Luz
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-03-26 00:00:00 Z
13
+ date: 2012-04-28 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: A JSON implementation as a JRuby extension.
@@ -23,66 +23,67 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - lib/json.rb
26
+ - lib/json/version.rb
26
27
  - lib/json/common.rb
27
28
  - lib/json/ext.rb
28
29
  - lib/json/pure.rb
29
- - lib/json/version.rb
30
- - lib/json/add/bigdecimal.rb
30
+ - lib/json/light_object.rb
31
+ - lib/json/add/symbol.rb
32
+ - lib/json/add/struct.rb
31
33
  - lib/json/add/complex.rb
32
- - lib/json/add/core.rb
33
- - lib/json/add/date.rb
34
- - lib/json/add/date_time.rb
34
+ - lib/json/add/rational.rb
35
35
  - lib/json/add/exception.rb
36
- - lib/json/add/ostruct.rb
36
+ - lib/json/add/time.rb
37
+ - lib/json/add/bigdecimal.rb
38
+ - lib/json/add/date_time.rb
39
+ - lib/json/add/core.rb
37
40
  - lib/json/add/range.rb
38
- - lib/json/add/rational.rb
41
+ - lib/json/add/date.rb
39
42
  - lib/json/add/regexp.rb
40
- - lib/json/add/struct.rb
41
- - lib/json/add/symbol.rb
42
- - lib/json/add/time.rb
43
- - lib/json/ext/generator.jar
44
- - lib/json/ext/parser.jar
43
+ - lib/json/add/ostruct.rb
45
44
  - lib/json/pure/generator.rb
46
45
  - lib/json/pure/parser.rb
46
+ - lib/json/ext/generator.jar
47
+ - lib/json/ext/parser.jar
48
+ - tests/test_json_string_matching.rb
49
+ - tests/test_json_fixtures.rb
47
50
  - tests/setup_variant.rb
48
- - tests/test_json.rb
51
+ - tests/test_json_unicode.rb
49
52
  - tests/test_json_addition.rb
50
- - tests/test_json_encoding.rb
51
- - tests/test_json_fixtures.rb
52
53
  - tests/test_json_generate.rb
53
- - tests/test_json_string_matching.rb
54
- - tests/test_json_unicode.rb
55
- - tests/fixtures/fail1.json
54
+ - tests/test_json_encoding.rb
55
+ - tests/test_json.rb
56
+ - tests/fixtures/fail6.json
57
+ - tests/fixtures/fail9.json
56
58
  - tests/fixtures/fail10.json
57
- - tests/fixtures/fail11.json
58
- - tests/fixtures/fail12.json
59
- - tests/fixtures/fail13.json
60
- - tests/fixtures/fail14.json
61
- - tests/fixtures/fail18.json
62
- - tests/fixtures/fail19.json
63
- - tests/fixtures/fail2.json
64
- - tests/fixtures/fail20.json
65
- - tests/fixtures/fail21.json
66
- - tests/fixtures/fail22.json
67
- - tests/fixtures/fail23.json
68
59
  - tests/fixtures/fail24.json
69
- - tests/fixtures/fail25.json
70
- - tests/fixtures/fail27.json
71
60
  - tests/fixtures/fail28.json
72
- - tests/fixtures/fail3.json
61
+ - tests/fixtures/fail13.json
73
62
  - tests/fixtures/fail4.json
74
- - tests/fixtures/fail5.json
75
- - tests/fixtures/fail6.json
76
- - tests/fixtures/fail7.json
77
- - tests/fixtures/fail8.json
78
- - tests/fixtures/fail9.json
79
- - tests/fixtures/pass1.json
80
- - tests/fixtures/pass15.json
63
+ - tests/fixtures/pass3.json
64
+ - tests/fixtures/fail11.json
65
+ - tests/fixtures/fail14.json
66
+ - tests/fixtures/fail3.json
67
+ - tests/fixtures/fail12.json
81
68
  - tests/fixtures/pass16.json
82
- - tests/fixtures/pass17.json
69
+ - tests/fixtures/pass15.json
70
+ - tests/fixtures/fail20.json
71
+ - tests/fixtures/fail8.json
83
72
  - tests/fixtures/pass2.json
73
+ - tests/fixtures/fail5.json
74
+ - tests/fixtures/fail1.json
75
+ - tests/fixtures/fail25.json
76
+ - tests/fixtures/pass17.json
77
+ - tests/fixtures/fail7.json
84
78
  - tests/fixtures/pass26.json
85
- - tests/fixtures/pass3.json
79
+ - tests/fixtures/fail21.json
80
+ - tests/fixtures/pass1.json
81
+ - tests/fixtures/fail23.json
82
+ - tests/fixtures/fail18.json
83
+ - tests/fixtures/fail2.json
84
+ - tests/fixtures/fail22.json
85
+ - tests/fixtures/fail27.json
86
+ - tests/fixtures/fail19.json
86
87
  homepage: http://json-jruby.rubyforge.org/
87
88
  licenses: []
88
89
 
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  requirements: []
113
114
 
114
115
  rubyforge_project: json-jruby
115
- rubygems_version: 1.8.21
116
+ rubygems_version: 1.8.22
116
117
  signing_key:
117
118
  specification_version: 3
118
119
  summary: JSON implementation for JRuby