json 3.0.1-java → 3.0.2-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6172ab55daf2cd89c12ee78ff4262de865bd7dfd20f40ad8669353b78ebaa8d8
4
- data.tar.gz: c87e0ad55b7637f1d691af7bae9ec9c261622aa49b1c66bd3cb80d5a0e6b9c1b
3
+ metadata.gz: 4be775fd0d4221af4703313be47b36df730b542f95063025472d82386bc6f949
4
+ data.tar.gz: aa1136bf72ebb55174ab30a3ddcaf908364a7e0cde743b952435a5ab59195d0a
5
5
  SHA512:
6
- metadata.gz: 26761f2f23036bc7aa235eb016d2fe28eac9a21b5c4efae05a987a7461550f356c9d7435f59b87646cb15b9383e04e42e9211354a9d1e6c7be4847c835b85be6
7
- data.tar.gz: 5f5825feaa01223c314de88082508f6928e5171cb65114d8ed51b2636c546a078fbce9294a6baec61d0058492638c89fe110745add121cf14d87fb1d494eb1f7
6
+ metadata.gz: 3b1da37df8ae7d0a8a40e41caed988f2b9f33c8ef147e66220e811adbc26199482189055badf0023bc5c4b8f201f2954a30cfa355cd7629604485c0424869f06
7
+ data.tar.gz: 7e50467d636c6a30b701d4778650355e6856660add1de37eef2519865977107e715cf19d3bcceff288ee068b5993908535243b6b799f7bc37bd7f41b8c270d37
data/CHANGES.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ### Unreleased
4
4
 
5
+ ### 2026-09-09 (3.0.2)
6
+
7
+ * Fix `JSON.load_file` and `JSON.load_file!` to load on Ruby 2.7.0 through 2.7.2, which cannot parse a leading parameter before `...`.
8
+
5
9
  ### 2026-09-08 (3.0.1)
6
10
 
7
11
  * Restore the `limit` positional argument of `JSON.dump`.
data/lib/json/common.rb CHANGED
@@ -143,11 +143,11 @@ module JSON
143
143
  # This exception is raised if a parser error occurs.
144
144
  class ParserError < JSONError
145
145
  # Line number where the parser encountered an error.
146
- # Is <tt>nil</tt> when raised by JSON::ResumableParser.
146
+ # Is +nil+ when raised by JSON::ResumableParser.
147
147
  attr_reader :line
148
148
 
149
149
  # Column number where the parser encountered an error.
150
- # Is <tt>nil</tt> when raised by JSON::ResumableParser.
150
+ # Is +nil+ when raised by JSON::ResumableParser.
151
151
  attr_reader :column
152
152
 
153
153
  # Returns a best effort JSONPath string representing where in the document
@@ -290,7 +290,7 @@ module JSON
290
290
  # ---
291
291
  #
292
292
  # Raises an exception if +source+ is not valid JSON:
293
- # # Raises JSON::ParserError unexpected character: 'invalid' at line 1 column 1 :
293
+ # # Raises JSON::ParserError (unexpected character: 'invalid' at line 1 column 1):
294
294
  # JSON.parse('invalid')
295
295
  #
296
296
  def parse(source, on_load: nil, object_class: nil, array_class: nil, **options)
@@ -324,8 +324,8 @@ module JSON
324
324
  # parse(File.read(path), **)
325
325
  #
326
326
  # See method #parse.
327
- def load_file(filespec, ...)
328
- parse(File.read(filespec, encoding: Encoding::UTF_8), ...)
327
+ def load_file(filespec, **options)
328
+ parse(File.read(filespec, encoding: Encoding::UTF_8), **options)
329
329
  end
330
330
 
331
331
  # :call-seq:
@@ -335,8 +335,8 @@ module JSON
335
335
  # JSON.parse!(File.read(path), **)
336
336
  #
337
337
  # See method #parse!
338
- def load_file!(filespec, ...)
339
- parse!(File.read(filespec, encoding: Encoding::UTF_8), ...)
338
+ def load_file!(filespec, **options)
339
+ parse!(File.read(filespec, encoding: Encoding::UTF_8), **options)
340
340
  end
341
341
 
342
342
  # :call-seq:
@@ -372,7 +372,7 @@ module JSON
372
372
  #
373
373
  # Raises an exception if +obj+ contains circular references:
374
374
  # a = []; b = []; a.push(b); b.push(a)
375
- # # Raises JSON::NestingError (nesting of 100 is too deep):
375
+ # # Raises JSON::NestingError (nesting of 100 is too deep. Did you try to serialize objects with circular references?):
376
376
  # JSON.generate(a)
377
377
  #
378
378
  def generate(obj, opts = nil)
@@ -812,9 +812,9 @@ module JSON
812
812
  private_constant :EXCLUDED_GENERATOR_OPTIONS
813
813
 
814
814
  # :call-seq:
815
- # JSON.new(options = nil, &block)
815
+ # JSON::Coder.new(**options, &block)
816
816
  #
817
- # Argument +options+, if given, contains a \Hash of options for both parsing and generating.
817
+ # Keyword arguments +options+, if given, are options for both parsing and generating.
818
818
  # See {Parsing Options}[rdoc-ref:JSON@Parsing+Options],
819
819
  # and {Generating Options}[rdoc-ref:JSON@Generating+Options].
820
820
  #
Binary file
Binary file
data/lib/json/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSON
4
- VERSION = '3.0.1'
4
+ VERSION = '3.0.2'
5
5
  end
data/lib/json.rb CHANGED
@@ -44,13 +44,13 @@ require 'json/common'
44
44
  #
45
45
  # You can parse a \String containing \JSON data using
46
46
  # either of two methods:
47
- # - <tt>JSON.parse(source, opts)</tt>
48
- # - <tt>JSON.parse!(source, opts)</tt>
47
+ # - <tt>JSON.parse(source, **opts)</tt>
48
+ # - <tt>JSON.parse!(source, **opts)</tt>
49
49
  #
50
50
  # where
51
51
  # - +source+ is a Ruby object.
52
- # - +opts+ is a \Hash object containing options
53
- # that control both input allowed and output formatting.
52
+ # - +opts+ are keyword arguments that control both input
53
+ # allowed and output formatting.
54
54
  #
55
55
  # The difference between the two methods
56
56
  # is that JSON.parse! omits some checks
@@ -102,7 +102,7 @@ require 'json/common'
102
102
  # ruby # => 1.0
103
103
  # ruby.class # => Float
104
104
  # ruby = JSON.parse('2.0e2')
105
- # ruby # => 200
105
+ # ruby # => 200.0
106
106
  # ruby.class # => Float
107
107
  # Boolean:
108
108
  # ruby = JSON.parse('true')
@@ -131,10 +131,10 @@ require 'json/common'
131
131
  # ruby # => [0, [1, [2, [3]]]]
132
132
  # Too deep:
133
133
  # # Raises JSON::NestingError (nesting of 2 is too deep):
134
- # JSON.parse(source, {max_nesting: 1})
134
+ # JSON.parse(source, max_nesting: 1)
135
135
  # Bad value:
136
- # # Raises TypeError (wrong argument type Symbol (expected Fixnum)):
137
- # JSON.parse(source, {max_nesting: :foo})
136
+ # # Raises TypeError (no implicit conversion of Symbol into Integer):
137
+ # JSON.parse(source, max_nesting: :foo)
138
138
  #
139
139
  # ---
140
140
  #
@@ -142,11 +142,11 @@ require 'json/common'
142
142
  # should be ignored or cause an error to be raised:
143
143
  #
144
144
  # When set to +false+, the default:
145
- # JSON.parse('{"a": 1, "a":2}') => duplicate key at line 1 column 1 (JSON::ParserError)
145
+ # JSON.parse('{"a": 1, "a": 2}') # duplicate key "a" at line 1 column 1 (JSON::ParserError)
146
146
  #
147
147
  # When set to +true+:
148
148
  # # The last value is used.
149
- # JSON.parse('{"a": 1, "a":2}', allow_duplicate_key: true) => {"a" => 2}
149
+ # JSON.parse('{"a": 1, "a": 2}', allow_duplicate_key: true) # => {"a" => 2}
150
150
  #
151
151
  # ---
152
152
  #
@@ -155,15 +155,15 @@ require 'json/common'
155
155
  # defaults to +false+.
156
156
  #
157
157
  # With the default, +false+:
158
- # # Raises JSON::ParserError (225: unexpected token at '[NaN]'):
158
+ # # Raises JSON::ParserError (unexpected token 'NaN]' at line 1 column 2):
159
159
  # JSON.parse('[NaN]')
160
- # # Raises JSON::ParserError (232: unexpected token at '[Infinity]'):
160
+ # # Raises JSON::ParserError (unexpected token 'Infinity]' at line 1 column 2):
161
161
  # JSON.parse('[Infinity]')
162
- # # Raises JSON::ParserError (248: unexpected token at '[-Infinity]'):
162
+ # # Raises JSON::ParserError (invalid number: '-Infinity]' at line 1 column 2):
163
163
  # JSON.parse('[-Infinity]')
164
164
  # Allow:
165
165
  # source = '[NaN, Infinity, -Infinity]'
166
- # ruby = JSON.parse(source, {allow_nan: true})
166
+ # ruby = JSON.parse(source, allow_nan: true)
167
167
  # ruby # => [NaN, Infinity, -Infinity]
168
168
  #
169
169
  # ---
@@ -185,10 +185,10 @@ require 'json/common'
185
185
  # defaults to +false+.
186
186
  #
187
187
  # When set to +false+, the default:
188
- # JSON.parse('/* comment */ {"a": 1, "a":2}') # unexpected character: '/' at line 1 column 1 (JSON::ParserError)
188
+ # JSON.parse('/* comment */ {"a": 1, "a": 2}') # unexpected token '/*' at line 1 column 1 (JSON::ParserError)
189
189
  #
190
190
  # When set to +true+, comments are ignored:
191
- # JSON.parse('/* comment */ {"a": 1, "a":2} // more comment') # => {"a" => 2}
191
+ # JSON.parse('/* comment */ {"a": 1} // more comment', allow_comments: true) # => {"a" => 1}
192
192
  #
193
193
  # ---
194
194
  #
@@ -197,7 +197,7 @@ require 'json/common'
197
197
  # defaults to +false+.
198
198
  #
199
199
  # With the default, +false+:
200
- # JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string (JSON::ParserError)
200
+ # JSON.parse(%{"Hello\nWorld"}) # invalid ASCII control character in string: \nWorld" at line 2 column 0 (JSON::ParserError)
201
201
  #
202
202
  # When enabled:
203
203
  # JSON.parse(%{"Hello\nWorld"}, allow_control_characters: true) # => "Hello\nWorld"
@@ -209,7 +209,7 @@ require 'json/common'
209
209
  # defaults to +false+.
210
210
  #
211
211
  # With the default, +false+:
212
- # JSON.parse('"Hell\o"') # invalid escape character in string (JSON::ParserError)
212
+ # JSON.parse('"Hell\o"') # invalid escape character in string: '\o"' at line 1 column 6 (JSON::ParserError)
213
213
  #
214
214
  # When enabled:
215
215
  # JSON.parse('"Hell\o"', allow_invalid_escape: true) # => "Hello"
@@ -228,8 +228,8 @@ require 'json/common'
228
228
  # ruby = JSON.parse(source)
229
229
  # ruby # => {"a"=>"foo", "b"=>1.0, "c"=>true, "d"=>false, "e"=>nil}
230
230
  # Use Symbols:
231
- # ruby = JSON.parse(source, {symbolize_names: true})
232
- # ruby # => {:a=>"foo", :b=>1.0, :c=>true, :d=>false, :e=>nil}
231
+ # ruby = JSON.parse(source, symbolize_names: true)
232
+ # ruby # => {a: "foo", b: 1.0, c: true, d: false, e: nil}
233
233
  #
234
234
  # ---
235
235
  #
@@ -242,7 +242,7 @@ require 'json/common'
242
242
  # ruby = JSON.parse(source)
243
243
  # ruby.class # => Hash
244
244
  # Use class \OpenStruct:
245
- # ruby = JSON.parse(source, {object_class: OpenStruct})
245
+ # ruby = JSON.parse(source, object_class: OpenStruct)
246
246
  # ruby # => #<OpenStruct a="foo", b=1.0, c=true, d=false, e=nil>
247
247
  #
248
248
  # ---
@@ -256,8 +256,8 @@ require 'json/common'
256
256
  # ruby = JSON.parse(source)
257
257
  # ruby.class # => Array
258
258
  # Use class \Set:
259
- # ruby = JSON.parse(source, {array_class: Set})
260
- # ruby # => #<Set: {"foo", 1.0, true, false, nil}>
259
+ # ruby = JSON.parse(source, array_class: Set)
260
+ # ruby # => Set["foo", 1.0, true, false, nil]
261
261
  #
262
262
  # === Generating \JSON
263
263
  #
@@ -319,22 +319,22 @@ require 'json/common'
319
319
  # a \String containing a \JSON string representation of the source:
320
320
  # JSON.generate(:foo) # => '"foo"'
321
321
  # JSON.generate(Complex(0, 0)) # => '"0+0i"'
322
- # JSON.generate(Dir.new('.')) # => '"#<Dir>"'
322
+ # JSON.generate(Dir.new('.')) # => '"#<Dir:0x...>"'
323
323
  #
324
324
  # ==== Generating Options
325
325
  #
326
326
  # ====== Input Options
327
327
  #
328
328
  # Option +allow_nan+ (boolean) specifies whether
329
- # +NaN+, +Infinity+, and <tt>-Infinity</tt> may be generated;
329
+ # +NaN+, +Infinity+, and +-Infinity+ may be generated;
330
330
  # defaults to +false+.
331
331
  #
332
332
  # With the default, +false+:
333
- # # Raises JSON::GeneratorError (920: NaN not allowed in JSON):
333
+ # # Raises JSON::GeneratorError (NaN not allowed in JSON):
334
334
  # JSON.generate(JSON::NaN)
335
- # # Raises JSON::GeneratorError (917: Infinity not allowed in JSON):
335
+ # # Raises JSON::GeneratorError (Infinity not allowed in JSON):
336
336
  # JSON.generate(JSON::Infinity)
337
- # # Raises JSON::GeneratorError (917: -Infinity not allowed in JSON):
337
+ # # Raises JSON::GeneratorError (-Infinity not allowed in JSON):
338
338
  # JSON.generate(JSON::MinusInfinity)
339
339
  #
340
340
  # Allow:
@@ -345,14 +345,14 @@ require 'json/common'
345
345
  #
346
346
  # Option +allow_duplicate_key+ (boolean) specifies whether
347
347
  # hashes with duplicate keys should be allowed or produce an error.
348
- # defaults to emit a deprecation warning.
348
+ # Defaults to +false+, which raises an error.
349
349
  #
350
- # With the default, <tt>false</tt>:
351
- # JSON.generate({ foo: 1, "foo" => 2 })
350
+ # With the default, +false+:
351
+ # JSON.generate({foo: 1, "foo" => 2})
352
352
  # # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
353
353
  #
354
- # With <tt>true</tt>
355
- # JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: true)
354
+ # With +true+:
355
+ # JSON.generate({foo: 1, "foo" => 2}, allow_duplicate_key: true)
356
356
  # # => '{"foo":1,"foo":2}'
357
357
  #
358
358
  # ---
@@ -365,13 +365,13 @@ require 'json/common'
365
365
  # JSON.generate(obj) # => '[[[[[[0]]]]]]'
366
366
  #
367
367
  # Too deep:
368
- # # Raises JSON::NestingError (nesting of 2 is too deep):
368
+ # # Raises JSON::NestingError (nesting of 2 is too deep. Did you try to serialize objects with circular references?):
369
369
  # JSON.generate(obj, max_nesting: 2)
370
370
  #
371
371
  # With +false+:
372
372
  # obj = []
373
373
  # obj[0] = obj
374
- # # Raises SystemStackError: stack level too deep
374
+ # # Raises SystemStackError (stack level too deep):
375
375
  # JSON.generate(obj, max_nesting: false)
376
376
  #
377
377
  # Setting +max_nesting+ to +false+ or a very large number can lead to a stack overflow
@@ -410,7 +410,7 @@ require 'json/common'
410
410
  # inserted before the colon in each \JSON object's pair;
411
411
  # defaults to the empty \String, <tt>''</tt>.
412
412
  # - Option +sort_keys+ (boolean or \Proc) controls whether and how the keys of a
413
- # hash are sorted when generating the output; defaults to <tt>false</tt>.
413
+ # hash are sorted when generating the output; defaults to +false+.
414
414
  # When +true+, keys are sorted lexicographically. When a \Proc, it receives
415
415
  # the entire \Hash and must return a \Hash with its pairs in the desired
416
416
  # order, allowing for arbitrary sort orders.
@@ -439,7 +439,7 @@ require 'json/common'
439
439
  # "foo" : [
440
440
  # "bar",
441
441
  # "baz"
442
- # ],
442
+ # ],
443
443
  # "bat" : {
444
444
  # "bam" : 0,
445
445
  # "bad" : 1
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: java
6
6
  authors:
7
7
  - Daniel Luz
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-09-08 00:00:00.000000000 Z
10
+ date: 2026-09-09 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: A JSON implementation as a JRuby extension.
13
13
  email: dev+ruby@mernen.com