json 2.10.1-java → 2.11.0-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: '0934358f40719c30e11b26cc88be54567810756f5d3e1780dcb8df044c0b0edf'
4
- data.tar.gz: 3f25af4cc0426962573ca281fc8b6754bcc42acd31f8f7a632217ef7c62a18f0
3
+ metadata.gz: a0d85104a64d3c5156e12808d6b33038dcdc91cdefc30f59d6499e497dea0fde
4
+ data.tar.gz: 780cdc27486cc84264b0faedf37f58b2b7119ebcbdc6fe89ac2cdfe620b78948
5
5
  SHA512:
6
- metadata.gz: 852e330449b1818df216c9f75296b7d6355832f7cb05e68bab8fbfb8254b87256ac84741119664c7dc43d28628b7b16ebe92d5b1d71aa478ffc50e56f94b90d3
7
- data.tar.gz: 32924b92e629577a14c7e567330b0752ec98a76568a1f4a010cd277fdf611bbcdb7226bbbcb9ddb919e8f9adac58ba47c25005d14aed57d69fd413ec1fd39f97
6
+ metadata.gz: '002833edb0ed24904b470dfbd09c6bff89ca27a4fcf3fa7f4118ca47af661e22c59678f1fe865e97fa146cd08b821bc0c3970b18021e06a727bf38c2518e636c'
7
+ data.tar.gz: fd38b0538130ffd17d4dab778150061ab263a943d2bd213c1884c7d9372912c7ed40f56fe3351246d348c4f9671d51e31748590dd6ee01f06e7bd7b0948cf609
data/CHANGES.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changes
2
2
 
3
+ ### 2025-04-24 (2.11.0)
4
+
5
+ * Optimize Integer generation to be ~1.8x faster.
6
+ * Optimize Float generation to be ~10x faster.
7
+ * Fix `JSON.load` proc argument to substitute the parsed object with the return value.
8
+ This better match `Marshal.load` behavior.
9
+ * Deprecate `JSON.fast_generate` (it's not any faster, so pointless).
10
+ * Deprecate `JSON.load_default_options`.
11
+ * Deprecate `JSON.unsafe_load_default_options`.
12
+ * Deprecate `JSON.dump_default_options`.
13
+ * Deprecate `Kernel#j`
14
+ * Deprecate `Kernel#jj`
15
+ * Remove outdated `JSON.iconv`.
16
+ * Remove `Class#json_creatable?` monkey patch.
17
+ * Remove deprecated `JSON.restore` method.
18
+ * Remove deprecated `JSON.unparse` method.
19
+ * Remove deprecated `JSON.fast_unparse` method.
20
+ * Remove deprecated `JSON.pretty_unparse` method.
21
+ * Remove deprecated `JSON::UnparserError` constant.
22
+ * Remove outdated `JSON::MissingUnicodeSupport` constant.
23
+
24
+ ### 2025-03-12 (2.10.2)
25
+
26
+ * Fix a potential crash in the C extension parser.
27
+ * Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` unadvertently changed it.
28
+ * Ensure document snippets that are included in parser errors don't include truncated multibyte characters.
29
+ * Ensure parser error snippets are valid UTF-8.
30
+ * Fix `JSON::GeneratorError#detailed_message` on Ruby < 3.2
31
+
3
32
  ### 2025-02-10 (2.10.1)
4
33
 
5
34
  * Fix a compatibility issue with `MultiJson.dump(obj, pretty: true)`: `no implicit conversion of false into Proc (TypeError)`.
data/lib/json/common.rb CHANGED
@@ -5,8 +5,111 @@ require 'json/version'
5
5
  module JSON
6
6
  autoload :GenericObject, 'json/generic_object'
7
7
 
8
- NOT_SET = Object.new.freeze
9
- private_constant :NOT_SET
8
+ module ParserOptions # :nodoc:
9
+ class << self
10
+ def prepare(opts)
11
+ if opts[:object_class] || opts[:array_class]
12
+ opts = opts.dup
13
+ on_load = opts[:on_load]
14
+
15
+ on_load = object_class_proc(opts[:object_class], on_load) if opts[:object_class]
16
+ on_load = array_class_proc(opts[:array_class], on_load) if opts[:array_class]
17
+ opts[:on_load] = on_load
18
+ end
19
+
20
+ if opts.fetch(:create_additions, false) != false
21
+ opts = create_additions_proc(opts)
22
+ end
23
+
24
+ opts
25
+ end
26
+
27
+ private
28
+
29
+ def object_class_proc(object_class, on_load)
30
+ ->(obj) do
31
+ if Hash === obj
32
+ object = object_class.new
33
+ obj.each { |k, v| object[k] = v }
34
+ obj = object
35
+ end
36
+ on_load.nil? ? obj : on_load.call(obj)
37
+ end
38
+ end
39
+
40
+ def array_class_proc(array_class, on_load)
41
+ ->(obj) do
42
+ if Array === obj
43
+ array = array_class.new
44
+ obj.each { |v| array << v }
45
+ obj = array
46
+ end
47
+ on_load.nil? ? obj : on_load.call(obj)
48
+ end
49
+ end
50
+
51
+ # TODO: exctract :create_additions support to another gem for version 3.0
52
+ def create_additions_proc(opts)
53
+ if opts[:symbolize_names]
54
+ raise ArgumentError, "options :symbolize_names and :create_additions cannot be used in conjunction"
55
+ end
56
+
57
+ opts = opts.dup
58
+ create_additions = opts.fetch(:create_additions, false)
59
+ on_load = opts[:on_load]
60
+ object_class = opts[:object_class] || Hash
61
+
62
+ opts[:on_load] = ->(object) do
63
+ case object
64
+ when String
65
+ opts[:match_string]&.each do |pattern, klass|
66
+ if match = pattern.match(object)
67
+ create_additions_warning if create_additions.nil?
68
+ object = klass.json_create(object)
69
+ break
70
+ end
71
+ end
72
+ when object_class
73
+ if opts[:create_additions] != false
74
+ if class_name = object[JSON.create_id]
75
+ klass = JSON.deep_const_get(class_name)
76
+ if (klass.respond_to?(:json_creatable?) && klass.json_creatable?) || klass.respond_to?(:json_create)
77
+ create_additions_warning if create_additions.nil?
78
+ object = klass.json_create(object)
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ on_load.nil? ? object : on_load.call(object)
85
+ end
86
+
87
+ opts
88
+ end
89
+
90
+ GEM_ROOT = File.expand_path("../../../", __FILE__) + "/"
91
+ def create_additions_warning
92
+ message = "JSON.load implicit support for `create_additions: true` is deprecated " \
93
+ "and will be removed in 3.0, use JSON.unsafe_load or explicitly " \
94
+ "pass `create_additions: true`"
95
+
96
+ uplevel = 4
97
+ caller_locations(uplevel, 10).each do |frame|
98
+ if frame.path.nil? || frame.path.start_with?(GEM_ROOT) || frame.path.end_with?("/truffle/cext_ruby.rb", ".c")
99
+ uplevel += 1
100
+ else
101
+ break
102
+ end
103
+ end
104
+
105
+ if RUBY_VERSION >= "3.0"
106
+ warn(message, uplevel: uplevel - 1, category: :deprecated)
107
+ else
108
+ warn(message, uplevel: uplevel - 1)
109
+ end
110
+ end
111
+ end
112
+ end
10
113
 
11
114
  class << self
12
115
  # :call-seq:
@@ -20,7 +123,7 @@ module JSON
20
123
  # Otherwise, calls JSON.generate with +object+ and +opts+ (see method #generate):
21
124
  # ruby = [0, 1, nil]
22
125
  # JSON[ruby] # => '[0,1,null]'
23
- def [](object, opts = {})
126
+ def [](object, opts = nil)
24
127
  if object.is_a?(String)
25
128
  return JSON.parse(object, opts)
26
129
  elsif object.respond_to?(:to_str)
@@ -70,37 +173,38 @@ module JSON
70
173
  end
71
174
  self.state = generator::State
72
175
  const_set :State, self.state
73
- const_set :SAFE_STATE_PROTOTYPE, State.new # for JRuby
74
- const_set :FAST_STATE_PROTOTYPE, create_fast_state
75
- const_set :PRETTY_STATE_PROTOTYPE, create_pretty_state
76
176
  ensure
77
177
  $VERBOSE = old
78
178
  end
79
179
 
80
- def create_fast_state
81
- State.new(
82
- :indent => '',
83
- :space => '',
84
- :object_nl => "",
85
- :array_nl => "",
86
- :max_nesting => false
87
- )
88
- end
89
-
90
- def create_pretty_state
91
- State.new(
92
- :indent => ' ',
93
- :space => ' ',
94
- :object_nl => "\n",
95
- :array_nl => "\n"
96
- )
97
- end
98
-
99
180
  # Returns the JSON generator module that is used by JSON.
100
181
  attr_reader :generator
101
182
 
102
183
  # Sets or Returns the JSON generator state class that is used by JSON.
103
184
  attr_accessor :state
185
+
186
+ private
187
+
188
+ def deprecated_singleton_attr_accessor(*attrs)
189
+ args = RUBY_VERSION >= "3.0" ? ", category: :deprecated" : ""
190
+ attrs.each do |attr|
191
+ singleton_class.class_eval <<~RUBY
192
+ def #{attr}
193
+ warn "JSON.#{attr} is deprecated and will be removed in json 3.0.0", uplevel: 1 #{args}
194
+ @#{attr}
195
+ end
196
+
197
+ def #{attr}=(val)
198
+ warn "JSON.#{attr}= is deprecated and will be removed in json 3.0.0", uplevel: 1 #{args}
199
+ @#{attr} = val
200
+ end
201
+
202
+ def _#{attr}
203
+ @#{attr}
204
+ end
205
+ RUBY
206
+ end
207
+ end
104
208
  end
105
209
 
106
210
  # Sets create identifier, which is used to decide if the _json_create_
@@ -116,20 +220,14 @@ module JSON
116
220
  Thread.current[:"JSON.create_id"] || 'json_class'
117
221
  end
118
222
 
119
- NaN = 0.0/0
223
+ NaN = Float::NAN
120
224
 
121
- Infinity = 1.0/0
225
+ Infinity = Float::INFINITY
122
226
 
123
227
  MinusInfinity = -Infinity
124
228
 
125
229
  # The base exception for JSON errors.
126
- class JSONError < StandardError
127
- def self.wrap(exception)
128
- obj = new("Wrapped(#{exception.class}): #{exception.message.inspect}")
129
- obj.set_backtrace exception.backtrace
130
- obj
131
- end
132
- end
230
+ class JSONError < StandardError; end
133
231
 
134
232
  # This exception is raised if a parser error occurs.
135
233
  class ParserError < JSONError; end
@@ -138,10 +236,6 @@ module JSON
138
236
  # deep.
139
237
  class NestingError < ParserError; end
140
238
 
141
- # :stopdoc:
142
- class CircularDatastructure < NestingError; end
143
- # :startdoc:
144
-
145
239
  # This exception is raised if a generator or unparser error occurs.
146
240
  class GeneratorError < JSONError
147
241
  attr_reader :invalid_object
@@ -152,21 +246,17 @@ module JSON
152
246
  end
153
247
 
154
248
  def detailed_message(...)
249
+ # Exception#detailed_message doesn't exist until Ruby 3.2
250
+ super_message = defined?(super) ? super : message
251
+
155
252
  if @invalid_object.nil?
156
- super
253
+ super_message
157
254
  else
158
- "#{super}\nInvalid object: #{@invalid_object.inspect}"
255
+ "#{super_message}\nInvalid object: #{@invalid_object.inspect}"
159
256
  end
160
257
  end
161
258
  end
162
259
 
163
- # For backwards compatibility
164
- UnparserError = GeneratorError # :nodoc:
165
-
166
- # This exception is raised if the required unicode support is missing on the
167
- # system. Usually this means that the iconv library is not installed.
168
- class MissingUnicodeSupport < JSONError; end
169
-
170
260
  # Fragment of JSON document that is to be included as is:
171
261
  # fragment = JSON::Fragment.new("[1, 2, 3]")
172
262
  # JSON.generate({ count: 3, items: fragments })
@@ -242,9 +332,16 @@ module JSON
242
332
  # JSON.parse('')
243
333
  #
244
334
  def parse(source, opts = nil)
335
+ opts = ParserOptions.prepare(opts) unless opts.nil?
245
336
  Parser.parse(source, opts)
246
337
  end
247
338
 
339
+ PARSE_L_OPTIONS = {
340
+ max_nesting: false,
341
+ allow_nan: true,
342
+ }.freeze
343
+ private_constant :PARSE_L_OPTIONS
344
+
248
345
  # :call-seq:
249
346
  # JSON.parse!(source, opts) -> object
250
347
  #
@@ -257,12 +354,11 @@ module JSON
257
354
  # which disables checking for nesting depth.
258
355
  # - Option +allow_nan+, if not provided, defaults to +true+.
259
356
  def parse!(source, opts = nil)
260
- options = {
261
- :max_nesting => false,
262
- :allow_nan => true
263
- }
264
- options.merge!(opts) if opts
265
- Parser.new(source, options).parse
357
+ if opts.nil?
358
+ parse(source, PARSE_L_OPTIONS)
359
+ else
360
+ parse(source, PARSE_L_OPTIONS.merge(opts))
361
+ end
266
362
  end
267
363
 
268
364
  # :call-seq:
@@ -331,13 +427,6 @@ module JSON
331
427
  end
332
428
  end
333
429
 
334
- # :stopdoc:
335
- # I want to deprecate these later, so I'll first be silent about them, and
336
- # later delete them.
337
- alias unparse generate
338
- module_function :unparse
339
- # :startdoc:
340
-
341
430
  # :call-seq:
342
431
  # JSON.fast_generate(obj, opts) -> new_string
343
432
  #
@@ -352,19 +441,21 @@ module JSON
352
441
  # # Raises SystemStackError (stack level too deep):
353
442
  # JSON.fast_generate(a)
354
443
  def fast_generate(obj, opts = nil)
355
- if State === opts
356
- state = opts
444
+ if RUBY_VERSION >= "3.0"
445
+ warn "JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1, category: :deprecated
357
446
  else
358
- state = JSON.create_fast_state.configure(opts)
447
+ warn "JSON.fast_generate is deprecated and will be removed in json 3.0.0, just use JSON.generate", uplevel: 1
359
448
  end
360
- state.generate(obj)
449
+ generate(obj, opts)
361
450
  end
362
451
 
363
- # :stopdoc:
364
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
365
- alias fast_unparse fast_generate
366
- module_function :fast_unparse
367
- # :startdoc:
452
+ PRETTY_GENERATE_OPTIONS = {
453
+ indent: ' ',
454
+ space: ' ',
455
+ object_nl: "\n",
456
+ array_nl: "\n",
457
+ }.freeze
458
+ private_constant :PRETTY_GENERATE_OPTIONS
368
459
 
369
460
  # :call-seq:
370
461
  # JSON.pretty_generate(obj, opts = nil) -> new_string
@@ -397,52 +488,46 @@ module JSON
397
488
  # }
398
489
  #
399
490
  def pretty_generate(obj, opts = nil)
400
- if State === opts
401
- state, opts = opts, nil
402
- else
403
- state = JSON.create_pretty_state
404
- end
491
+ return state.generate(obj) if State === opts
492
+
493
+ options = PRETTY_GENERATE_OPTIONS
494
+
405
495
  if opts
406
- if opts.respond_to? :to_hash
407
- opts = opts.to_hash
408
- elsif opts.respond_to? :to_h
409
- opts = opts.to_h
410
- else
411
- raise TypeError, "can't convert #{opts.class} into Hash"
496
+ unless opts.is_a?(Hash)
497
+ if opts.respond_to? :to_hash
498
+ opts = opts.to_hash
499
+ elsif opts.respond_to? :to_h
500
+ opts = opts.to_h
501
+ else
502
+ raise TypeError, "can't convert #{opts.class} into Hash"
503
+ end
412
504
  end
413
- state.configure(opts)
505
+ options = options.merge(opts)
414
506
  end
415
- state.generate(obj)
507
+
508
+ State.generate(obj, options, nil)
416
509
  end
417
510
 
418
- # :stopdoc:
419
- # I want to deprecate these later, so I'll first be silent about them, and later delete them.
420
- alias pretty_unparse pretty_generate
421
- module_function :pretty_unparse
422
- # :startdoc:
511
+ # Sets or returns default options for the JSON.unsafe_load method.
512
+ # Initially:
513
+ # opts = JSON.load_default_options
514
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
515
+ deprecated_singleton_attr_accessor :unsafe_load_default_options
423
516
 
424
- class << self
425
- # Sets or returns default options for the JSON.unsafe_load method.
426
- # Initially:
427
- # opts = JSON.load_default_options
428
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
429
- attr_accessor :unsafe_load_default_options
430
- end
431
- self.unsafe_load_default_options = {
517
+ @unsafe_load_default_options = {
432
518
  :max_nesting => false,
433
519
  :allow_nan => true,
434
520
  :allow_blank => true,
435
521
  :create_additions => true,
436
522
  }
437
523
 
438
- class << self
439
- # Sets or returns default options for the JSON.load method.
440
- # Initially:
441
- # opts = JSON.load_default_options
442
- # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
443
- attr_accessor :load_default_options
444
- end
445
- self.load_default_options = {
524
+ # Sets or returns default options for the JSON.load method.
525
+ # Initially:
526
+ # opts = JSON.load_default_options
527
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :allow_blank=>true, :create_additions=>true}
528
+ deprecated_singleton_attr_accessor :load_default_options
529
+
530
+ @load_default_options = {
446
531
  :allow_nan => true,
447
532
  :allow_blank => true,
448
533
  :create_additions => nil,
@@ -578,9 +663,9 @@ module JSON
578
663
  #
579
664
  def unsafe_load(source, proc = nil, options = nil)
580
665
  opts = if options.nil?
581
- unsafe_load_default_options
666
+ _unsafe_load_default_options
582
667
  else
583
- unsafe_load_default_options.merge(options)
668
+ _unsafe_load_default_options.merge(options)
584
669
  end
585
670
 
586
671
  unless source.is_a?(String)
@@ -738,9 +823,9 @@ module JSON
738
823
  #
739
824
  def load(source, proc = nil, options = nil)
740
825
  opts = if options.nil?
741
- load_default_options
826
+ _load_default_options
742
827
  else
743
- load_default_options.merge(options)
828
+ _load_default_options.merge(options)
744
829
  end
745
830
 
746
831
  unless source.is_a?(String)
@@ -756,36 +841,21 @@ module JSON
756
841
  if opts[:allow_blank] && (source.nil? || source.empty?)
757
842
  source = 'null'
758
843
  end
759
- result = parse(source, opts)
760
- recurse_proc(result, &proc) if proc
761
- result
762
- end
763
844
 
764
- # Recursively calls passed _Proc_ if the parsed data structure is an _Array_ or _Hash_
765
- def recurse_proc(result, &proc) # :nodoc:
766
- case result
767
- when Array
768
- result.each { |x| recurse_proc x, &proc }
769
- proc.call result
770
- when Hash
771
- result.each { |x, y| recurse_proc x, &proc; recurse_proc y, &proc }
772
- proc.call result
773
- else
774
- proc.call result
845
+ if proc
846
+ opts = opts.dup
847
+ opts[:on_load] = proc.to_proc
775
848
  end
776
- end
777
-
778
- alias restore load
779
- module_function :restore
780
849
 
781
- class << self
782
- # Sets or returns the default options for the JSON.dump method.
783
- # Initially:
784
- # opts = JSON.dump_default_options
785
- # opts # => {:max_nesting=>false, :allow_nan=>true}
786
- attr_accessor :dump_default_options
850
+ parse(source, opts)
787
851
  end
788
- self.dump_default_options = {
852
+
853
+ # Sets or returns the default options for the JSON.dump method.
854
+ # Initially:
855
+ # opts = JSON.dump_default_options
856
+ # opts # => {:max_nesting=>false, :allow_nan=>true}
857
+ deprecated_singleton_attr_accessor :dump_default_options
858
+ @dump_default_options = {
789
859
  :max_nesting => false,
790
860
  :allow_nan => true,
791
861
  }
@@ -838,9 +908,9 @@ module JSON
838
908
  end
839
909
  end
840
910
 
841
- opts = JSON.dump_default_options
911
+ opts = JSON._dump_default_options
842
912
  opts = opts.merge(:max_nesting => limit) if limit
843
- opts = merge_dump_options(opts, **kwargs) if kwargs
913
+ opts = opts.merge(kwargs) if kwargs
844
914
 
845
915
  begin
846
916
  State.generate(obj, opts, anIO)
@@ -849,20 +919,6 @@ module JSON
849
919
  end
850
920
  end
851
921
 
852
- # Encodes string using String.encode.
853
- def self.iconv(to, from, string)
854
- string.encode(to, from)
855
- end
856
-
857
- def merge_dump_options(opts, strict: NOT_SET)
858
- opts = opts.merge(strict: strict) if NOT_SET != strict
859
- opts
860
- end
861
-
862
- class << self
863
- private :merge_dump_options
864
- end
865
-
866
922
  # JSON::Coder holds a parser and generator configuration.
867
923
  #
868
924
  # module MyApp
@@ -905,10 +961,9 @@ module JSON
905
961
  options[:strict] = true
906
962
  end
907
963
  options[:as_json] = as_json if as_json
908
- options[:create_additions] = false unless options.key?(:create_additions)
909
964
 
910
965
  @state = State.new(options).freeze
911
- @parser_config = Ext::Parser::Config.new(options)
966
+ @parser_config = Ext::Parser::Config.new(ParserOptions.prepare(options))
912
967
  end
913
968
 
914
969
  # call-seq:
@@ -946,6 +1001,12 @@ module ::Kernel
946
1001
  # Outputs _objs_ to STDOUT as JSON strings in the shortest form, that is in
947
1002
  # one line.
948
1003
  def j(*objs)
1004
+ if RUBY_VERSION >= "3.0"
1005
+ warn "Kernel#j is deprecated and will be removed in json 3.0.0", uplevel: 1, category: :deprecated
1006
+ else
1007
+ warn "Kernel#j is deprecated and will be removed in json 3.0.0", uplevel: 1
1008
+ end
1009
+
949
1010
  objs.each do |obj|
950
1011
  puts JSON::generate(obj, :allow_nan => true, :max_nesting => false)
951
1012
  end
@@ -955,6 +1016,12 @@ module ::Kernel
955
1016
  # Outputs _objs_ to STDOUT as JSON strings in a pretty format, with
956
1017
  # indentation and over many lines.
957
1018
  def jj(*objs)
1019
+ if RUBY_VERSION >= "3.0"
1020
+ warn "Kernel#jj is deprecated and will be removed in json 3.0.0", uplevel: 1, category: :deprecated
1021
+ else
1022
+ warn "Kernel#jj is deprecated and will be removed in json 3.0.0", uplevel: 1
1023
+ end
1024
+
958
1025
  objs.each do |obj|
959
1026
  puts JSON::pretty_generate(obj, :allow_nan => true, :max_nesting => false)
960
1027
  end
@@ -967,27 +1034,7 @@ module ::Kernel
967
1034
  #
968
1035
  # The _opts_ argument is passed through to generate/parse respectively. See
969
1036
  # generate and parse for their documentation.
970
- def JSON(object, *args)
971
- if object.is_a?(String)
972
- return JSON.parse(object, args.first)
973
- elsif object.respond_to?(:to_str)
974
- str = object.to_str
975
- if str.is_a?(String)
976
- return JSON.parse(object.to_str, args.first)
977
- end
978
- end
979
-
980
- JSON.generate(object, args.first)
981
- end
982
- end
983
-
984
- # Extends any Class to include _json_creatable?_ method.
985
- class ::Class
986
- # Returns true if this class can be used to create an instance
987
- # from a serialised JSON string. The class has to implement a class
988
- # method _json_create_ that expects a hash as first parameter. The hash
989
- # should include the required data.
990
- def json_creatable?
991
- respond_to?(:json_create)
1037
+ def JSON(object, opts = nil)
1038
+ JSON[object, opts]
992
1039
  end
993
1040
  end
Binary file
Binary file
@@ -117,7 +117,7 @@ module JSON
117
117
  return new(opts.to_h)
118
118
  end
119
119
  end
120
- SAFE_STATE_PROTOTYPE.dup
120
+ new
121
121
  end
122
122
 
123
123
  # Instantiates a new State object, configured by _opts_.
data/lib/json/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSON
4
- VERSION = '2.10.1'
4
+ VERSION = '2.11.0'
5
5
  end
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.10.1
4
+ version: 2.11.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: 2025-02-10 00:00:00.000000000 Z
11
+ date: 2025-04-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A JSON implementation as a JRuby extension.
14
14
  email: dev+ruby@mernen.com