json 2.2.0-java → 2.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cbe28120a7a65d91699b5ad5e8f0c3b1c2c0895cc1bfd1d27de93513da6276c
4
- data.tar.gz: a79ed2632e93ef7dc2df67f197d56d4be671c61e94ebe59c298cc5d6bde668a3
3
+ metadata.gz: 7dedc6571d595948f39fafcb3a5b5f57a93baac5c7d71aa22743a713b2fc6408
4
+ data.tar.gz: 810d86047c05bb8dab727f6b624e30aba7d63711d694d8840eb2c716bffb4708
5
5
  SHA512:
6
- metadata.gz: 711bab89dfc319519f4f5818e87de1d1f12a4e4542b193e5dfdff50a0db12c31fe453a4353666257689b8d3ba2a3456bc818e65065f97e8ca2574add40b7b300
7
- data.tar.gz: 64b77395e18b73007922ea755f58048dc68262eaf040c12c944ed89fd422db468ed8ccce3c9904a65c6b58fd4848b5462e920cac9039140dfa1cf28db54decfe
6
+ metadata.gz: 47f0e1b42974dab1836d3acf3ec4f3a821475dddea2d393e168ad7385d9f894b9c9fc4eec453f803a702bedc0daf25d5274cd741ec3ff63ab67f6ab11183b3d1
7
+ data.tar.gz: aedd907a306c70eb77f610128ad3f208729ca9a6ff743e7f6e0a8100fe13d7c52963359c78b17144a0a1ec49c7a98588067fb14c3c950291dc932896ffffe371
@@ -23,7 +23,7 @@ class BigDecimal
23
23
  end
24
24
 
25
25
  # return the JSON value
26
- def to_json(*)
27
- as_json.to_json
26
+ def to_json(*args)
27
+ as_json.to_json(*args)
28
28
  end
29
29
  end
@@ -23,7 +23,7 @@ class Complex
23
23
  end
24
24
 
25
25
  # Stores class name (Complex) along with real value <tt>r</tt> and imaginary value <tt>i</tt> as JSON string
26
- def to_json(*)
27
- as_json.to_json
26
+ def to_json(*args)
27
+ as_json.to_json(*args)
28
28
  end
29
29
  end
@@ -22,7 +22,7 @@ class Rational
22
22
  end
23
23
 
24
24
  # Stores class name (Rational) along with numerator value <tt>n</tt> and denominator value <tt>d</tt> as JSON string
25
- def to_json(*)
26
- as_json.to_json
25
+ def to_json(*args)
26
+ as_json.to_json(*args)
27
27
  end
28
28
  end
@@ -24,7 +24,7 @@ class Regexp
24
24
 
25
25
  # Stores class name (Regexp) with options <tt>o</tt> and source <tt>s</tt>
26
26
  # (Regexp or String) as JSON string
27
- def to_json(*)
28
- as_json.to_json
27
+ def to_json(*args)
28
+ as_json.to_json(*args)
29
29
  end
30
30
  end
@@ -153,7 +153,7 @@ module JSON
153
153
  # * *object_class*: Defaults to Hash
154
154
  # * *array_class*: Defaults to Array
155
155
  def parse(source, opts = {})
156
- Parser.new(source, opts).parse
156
+ Parser.new(source, **(opts||{})).parse
157
157
  end
158
158
 
159
159
  # Parse the JSON document _source_ into a Ruby data structure and return it.
@@ -176,7 +176,7 @@ module JSON
176
176
  :max_nesting => false,
177
177
  :allow_nan => true
178
178
  }.merge(opts)
179
- Parser.new(source, opts).parse
179
+ Parser.new(source, **(opts||{})).parse
180
180
  end
181
181
 
182
182
  # Generate a JSON document from the Ruby data structure _obj_ and return
Binary file
Binary file
@@ -250,7 +250,8 @@ module JSON
250
250
  if respond_to?(name)
251
251
  __send__(name)
252
252
  else
253
- instance_variable_get("@#{name}")
253
+ instance_variable_get("@#{name}") if
254
+ instance_variables.include?("@#{name}".to_sym) # avoid warning
254
255
  end
255
256
  end
256
257
 
@@ -197,7 +197,15 @@ module JSON
197
197
  def parse_value
198
198
  case
199
199
  when scan(FLOAT)
200
- @decimal_class && @decimal_class.new(self[1]) || Float(self[1])
200
+ if @decimal_class then
201
+ if @decimal_class == BigDecimal then
202
+ BigDecimal(self[1])
203
+ else
204
+ @decimal_class.new(self[1]) || Float(self[1])
205
+ end
206
+ else
207
+ Float(self[1])
208
+ end
201
209
  when scan(INTEGER)
202
210
  Integer(self[1])
203
211
  when scan(TRUE)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
  module JSON
3
3
  # JSON version
4
- VERSION = '2.2.0'
4
+ VERSION = '2.3.0'
5
5
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
6
6
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
7
7
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -27,15 +27,15 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
27
27
  end
28
28
 
29
29
  def test_parser
30
- assert_match /::Parser\z/, JSON.parser.name
30
+ assert_match(/::Parser\z/, JSON.parser.name)
31
31
  end
32
32
 
33
33
  def test_generator
34
- assert_match /::Generator\z/, JSON.generator.name
34
+ assert_match(/::Generator\z/, JSON.generator.name)
35
35
  end
36
36
 
37
37
  def test_state
38
- assert_match /::Generator::State\z/, JSON.state.name
38
+ assert_match(/::Generator::State\z/, JSON.state.name)
39
39
  end
40
40
 
41
41
  def test_create_id
@@ -56,7 +56,7 @@ class JSONCommonInterfaceTest < Test::Unit::TestCase
56
56
  end
57
57
 
58
58
  def test_parse_bang
59
- assert_equal [ 1, NaN, 3, ], JSON.parse!('[ 1, NaN, 3 ]')
59
+ assert_equal [ 1, Infinity, 3, ], JSON.parse!('[ 1, Infinity, 3 ]')
60
60
  end
61
61
 
62
62
  def test_generate
@@ -40,6 +40,44 @@ class JSONGeneratorTest < Test::Unit::TestCase
40
40
  EOT
41
41
  end
42
42
 
43
+ def silence
44
+ v = $VERBOSE
45
+ $VERBOSE = nil
46
+ yield
47
+ ensure
48
+ $VERBOSE = v
49
+ end
50
+
51
+ def test_remove_const_segv
52
+ return if RUBY_ENGINE == 'jruby'
53
+ stress = GC.stress
54
+ const = JSON::SAFE_STATE_PROTOTYPE.dup
55
+
56
+ bignum_too_long_to_embed_as_string = 1234567890123456789012345
57
+ expect = bignum_too_long_to_embed_as_string.to_s
58
+ GC.stress = true
59
+
60
+ 10.times do |i|
61
+ tmp = bignum_too_long_to_embed_as_string.to_json
62
+ raise "'\#{expect}' is expected, but '\#{tmp}'" unless tmp == expect
63
+ end
64
+
65
+ silence do
66
+ JSON.const_set :SAFE_STATE_PROTOTYPE, nil
67
+ end
68
+
69
+ 10.times do |i|
70
+ assert_raise TypeError do
71
+ bignum_too_long_to_embed_as_string.to_json
72
+ end
73
+ end
74
+ ensure
75
+ GC.stress = stress
76
+ silence do
77
+ JSON.const_set :SAFE_STATE_PROTOTYPE, const
78
+ end
79
+ end if JSON.const_defined?("Ext")
80
+
43
81
  def test_generate
44
82
  json = generate(@hash)
45
83
  assert_equal(parse(@json2), parse(json))
@@ -374,4 +412,10 @@ EOT
374
412
  assert_equal '["foo"]', JSON.generate([s.new('foo')])
375
413
  end
376
414
  end
415
+
416
+ if defined?(Encoding)
417
+ def test_nonutf8_encoding
418
+ assert_equal("\"5\u{b0}\"", "5\xb0".force_encoding("iso-8859-1").to_json)
419
+ end
420
+ end
377
421
  end
@@ -91,27 +91,27 @@ class JSONParserTest < Test::Unit::TestCase
91
91
  assert_raise(JSON::ParserError) { parse('+23') }
92
92
  assert_raise(JSON::ParserError) { parse('.23') }
93
93
  assert_raise(JSON::ParserError) { parse('023') }
94
- assert_equal 23, parse('23')
95
- assert_equal -23, parse('-23')
96
- assert_equal_float 3.141, parse('3.141')
97
- assert_equal_float -3.141, parse('-3.141')
98
- assert_equal_float 3.141, parse('3141e-3')
99
- assert_equal_float 3.141, parse('3141.1e-3')
100
- assert_equal_float 3.141, parse('3141E-3')
101
- assert_equal_float 3.141, parse('3141.0E-3')
102
- assert_equal_float -3.141, parse('-3141.0e-3')
103
- assert_equal_float -3.141, parse('-3141e-3')
94
+ assert_equal(23, parse('23'))
95
+ assert_equal(-23, parse('-23'))
96
+ assert_equal_float(3.141, parse('3.141'))
97
+ assert_equal_float(-3.141, parse('-3.141'))
98
+ assert_equal_float(3.141, parse('3141e-3'))
99
+ assert_equal_float(3.141, parse('3141.1e-3'))
100
+ assert_equal_float(3.141, parse('3141E-3'))
101
+ assert_equal_float(3.141, parse('3141.0E-3'))
102
+ assert_equal_float(-3.141, parse('-3141.0e-3'))
103
+ assert_equal_float(-3.141, parse('-3141e-3'))
104
104
  assert_raise(ParserError) { parse('NaN') }
105
105
  assert parse('NaN', :allow_nan => true).nan?
106
106
  assert_raise(ParserError) { parse('Infinity') }
107
- assert_equal 1.0/0, parse('Infinity', :allow_nan => true)
107
+ assert_equal(1.0/0, parse('Infinity', :allow_nan => true))
108
108
  assert_raise(ParserError) { parse('-Infinity') }
109
- assert_equal -1.0/0, parse('-Infinity', :allow_nan => true)
109
+ assert_equal(-1.0/0, parse('-Infinity', :allow_nan => true))
110
110
  end
111
111
 
112
112
  def test_parse_bigdecimals
113
- assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class)
114
- assert_equal(BigDecimal.new("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] )
113
+ assert_equal(BigDecimal, JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"].class)
114
+ assert_equal(BigDecimal("0.901234567890123456789E1"),JSON.parse('{"foo": 9.01234567890123456789}', decimal_class: BigDecimal)["foo"] )
115
115
  end
116
116
 
117
117
  if Array.method_defined?(:permutation)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: java
6
6
  authors:
7
7
  - Daniel Luz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-21 00:00:00.000000000 Z
11
+ date: 2019-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ files:
109
109
  - tests/json_parser_test.rb
110
110
  - tests/json_string_matching_test.rb
111
111
  - tests/test_helper.rb
112
- homepage: http://json-jruby.rubyforge.org/
112
+ homepage: http://flori.github.com/json
113
113
  licenses:
114
114
  - Ruby
115
115
  metadata: {}
@@ -128,8 +128,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubyforge_project: json-jruby
132
- rubygems_version: 2.7.6
131
+ rubyforge_project:
132
+ rubygems_version: 2.7.10
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: JSON implementation for JRuby