json 2.13.1-java → 2.14.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 +4 -4
- data/CHANGES.md +29 -8
- data/lib/json/add/core.rb +1 -0
- data/lib/json/add/string.rb +35 -0
- data/lib/json/common.rb +49 -23
- data/lib/json/ext/generator/state.rb +7 -14
- data/lib/json/ext/generator.jar +0 -0
- data/lib/json/ext/parser.jar +0 -0
- data/lib/json/generic_object.rb +0 -8
- data/lib/json/truffle_ruby/generator.rb +45 -35
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +23 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf285376b5311a27df8445b1a11f04d363da0841b0d78e01a5bef242c9a9f043
|
4
|
+
data.tar.gz: c87f93c45bcf5d74c8f34e5c90a40f8f0e1fa031ce7265b63262d834c533e1a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 330c4f9af6227e5328988b26d6f5ab89f7c4a9be84b6e721f4458e317b2e61085bee5a8b819538a092205e8e88c834c8e1552e9c6cc0ed542e3441489850213e
|
7
|
+
data.tar.gz: 3bba15252557d73cf0c1ae6b9eb96914d11eb9b5e4115ea8fe2f0b5d7ad9f31c1ccb248051256111d2ba27b169095b7e61628e8909950ce8ef8126a200d209d8
|
data/CHANGES.md
CHANGED
@@ -2,6 +2,26 @@
|
|
2
2
|
|
3
3
|
### Unreleased
|
4
4
|
|
5
|
+
* Add new `allow_duplicate_key` generator options. By default a warning is now emitted when a duplicated key is encountered.
|
6
|
+
In `json 3.0` an error will be raised.
|
7
|
+
```ruby
|
8
|
+
>> Warning[:deprecated] = true
|
9
|
+
>> puts JSON.generate({ foo: 1, "foo" => 2 })
|
10
|
+
(irb):2: warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
|
11
|
+
This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
|
12
|
+
{"foo":1,"foo":2}
|
13
|
+
>> JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
|
14
|
+
detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
|
15
|
+
```
|
16
|
+
* Fix `JSON.generate` `strict: true` mode to also restrict hash keys.
|
17
|
+
* Fix `JSON::Coder` to also invoke block for hash keys that aren't strings nor symbols.
|
18
|
+
* Fix `JSON.unsafe_load` usage with proc
|
19
|
+
* Fix the parser to more consistently reject invalid UTF-16 surogate pairs.
|
20
|
+
|
21
|
+
### 2025-07-28 (2.13.2)
|
22
|
+
|
23
|
+
* Improve duplicate key warning and errors to include the key name and point to the right caller.
|
24
|
+
|
5
25
|
### 2025-07-24 (2.13.1)
|
6
26
|
|
7
27
|
* Fix support for older compilers without `__builtin_cpu_supports`.
|
@@ -40,7 +60,7 @@
|
|
40
60
|
### 2025-04-24 (2.11.1)
|
41
61
|
|
42
62
|
* Add back `JSON.restore`, `JSON.unparse`, `JSON.fast_unparse` and `JSON.pretty_unparse`.
|
43
|
-
These were deprecated 16 years ago, but never
|
63
|
+
These were deprecated 16 years ago, but never emitted warnings, only undocumented, so are
|
44
64
|
still used by a few gems.
|
45
65
|
|
46
66
|
### 2025-04-24 (2.11.0)
|
@@ -67,7 +87,7 @@
|
|
67
87
|
### 2025-03-12 (2.10.2)
|
68
88
|
|
69
89
|
* Fix a potential crash in the C extension parser.
|
70
|
-
* Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0`
|
90
|
+
* Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` inadvertently changed it.
|
71
91
|
* Ensure document snippets that are included in parser errors don't include truncated multibyte characters.
|
72
92
|
* Ensure parser error snippets are valid UTF-8.
|
73
93
|
* Fix `JSON::GeneratorError#detailed_message` on Ruby < 3.2
|
@@ -98,7 +118,7 @@
|
|
98
118
|
|
99
119
|
### 2024-11-14 (2.8.2)
|
100
120
|
|
101
|
-
* `JSON.load_file`
|
121
|
+
* `JSON.load_file` explicitly read the file as UTF-8.
|
102
122
|
|
103
123
|
### 2024-11-06 (2.8.1)
|
104
124
|
|
@@ -106,7 +126,7 @@
|
|
106
126
|
|
107
127
|
### 2024-11-06 (2.8.0)
|
108
128
|
|
109
|
-
* Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being
|
129
|
+
* Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explicitly enabled.
|
110
130
|
* Prefer to use `JSON.unsafe_load(string)` or `JSON.load(string, create_additions: true)`.
|
111
131
|
* Emit a deprecation warning when serializing valid UTF-8 strings encoded in `ASCII_8BIT` aka `BINARY`.
|
112
132
|
* Bump required Ruby version to 2.7.
|
@@ -114,7 +134,7 @@
|
|
114
134
|
pre-existing support for comments, make it suitable to parse `jsonc` documents.
|
115
135
|
* Many performance improvements to `JSON.parse` and `JSON.load`, up to `1.7x` faster on real world documents.
|
116
136
|
* Some minor performance improvements to `JSON.dump` and `JSON.generate`.
|
117
|
-
* `JSON.pretty_generate` no longer
|
137
|
+
* `JSON.pretty_generate` no longer includes newlines inside empty object and arrays.
|
118
138
|
|
119
139
|
### 2024-11-04 (2.7.6)
|
120
140
|
|
@@ -131,13 +151,13 @@
|
|
131
151
|
* Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490.
|
132
152
|
This bug would cause some gems with native extension to fail during compilation.
|
133
153
|
* Workaround different versions of `json` and `json_pure` being loaded (not officially supported).
|
134
|
-
* Make `json_pure` Ractor compatible.
|
154
|
+
* Make `json_pure` Ractor compatible.
|
135
155
|
|
136
156
|
### 2024-10-24 (2.7.3)
|
137
157
|
|
138
158
|
* Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
|
139
|
-
* Limit the size of ParserError exception messages, only include up to 32 bytes of the
|
140
|
-
* Fix json-pure's `Object#to_json` to accept non
|
159
|
+
* Limit the size of ParserError exception messages, only include up to 32 bytes of the unparsable source.
|
160
|
+
* Fix json-pure's `Object#to_json` to accept non-state arguments.
|
141
161
|
* Fix multiline comment support in `json-pure`.
|
142
162
|
* Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string.
|
143
163
|
* Fix `String#to_json` to raise on invalid encoding in `json-pure`.
|
@@ -282,6 +302,7 @@
|
|
282
302
|
## 2015-09-11 (2.0.0)
|
283
303
|
* Now complies to newest JSON RFC 7159.
|
284
304
|
* Implements compatibility to ruby 2.4 integer unification.
|
305
|
+
* Removed support for `quirks_mode` option.
|
285
306
|
* Drops support for old rubies whose life has ended, that is rubies < 2.0.
|
286
307
|
Also see https://www.ruby-lang.org/en/news/2014/07/01/eol-for-1-8-7-and-1-9-2/
|
287
308
|
* There were still some mentions of dual GPL licensing in the source, but JSON
|
data/lib/json/add/core.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
|
3
|
+
require 'json'
|
4
|
+
end
|
5
|
+
|
6
|
+
class String
|
7
|
+
# call-seq: json_create(o)
|
8
|
+
#
|
9
|
+
# Raw Strings are JSON Objects (the raw bytes are stored in an array for the
|
10
|
+
# key "raw"). The Ruby String can be created by this class method.
|
11
|
+
def self.json_create(object)
|
12
|
+
object["raw"].pack("C*")
|
13
|
+
end
|
14
|
+
|
15
|
+
# call-seq: to_json_raw_object()
|
16
|
+
#
|
17
|
+
# This method creates a raw object hash, that can be nested into
|
18
|
+
# other data structures and will be generated as a raw string. This
|
19
|
+
# method should be used, if you want to convert raw strings to JSON
|
20
|
+
# instead of UTF-8 strings, e. g. binary data.
|
21
|
+
def to_json_raw_object
|
22
|
+
{
|
23
|
+
JSON.create_id => self.class.name,
|
24
|
+
"raw" => unpack("C*"),
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# call-seq: to_json_raw(*args)
|
29
|
+
#
|
30
|
+
# This method creates a JSON text from the result of a call to
|
31
|
+
# to_json_raw_object of this String.
|
32
|
+
def to_json_raw(...)
|
33
|
+
to_json_raw_object.to_json(...)
|
34
|
+
end
|
35
|
+
end
|
data/lib/json/common.rb
CHANGED
@@ -48,7 +48,7 @@ module JSON
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
# TODO:
|
51
|
+
# TODO: extract :create_additions support to another gem for version 3.0
|
52
52
|
def create_additions_proc(opts)
|
53
53
|
if opts[:symbolize_names]
|
54
54
|
raise ArgumentError, "options :symbolize_names and :create_additions cannot be used in conjunction"
|
@@ -73,7 +73,7 @@ module JSON
|
|
73
73
|
if opts[:create_additions] != false
|
74
74
|
if class_name = object[JSON.create_id]
|
75
75
|
klass = JSON.deep_const_get(class_name)
|
76
|
-
if
|
76
|
+
if klass.respond_to?(:json_creatable?) ? klass.json_creatable? : klass.respond_to?(:json_create)
|
77
77
|
create_additions_warning if create_additions.nil?
|
78
78
|
object = klass.json_create(object)
|
79
79
|
end
|
@@ -87,31 +87,32 @@ module JSON
|
|
87
87
|
opts
|
88
88
|
end
|
89
89
|
|
90
|
-
GEM_ROOT = File.expand_path("../../../", __FILE__) + "/"
|
91
90
|
def create_additions_warning
|
92
|
-
|
91
|
+
JSON.deprecation_warning "JSON.load implicit support for `create_additions: true` is deprecated " \
|
93
92
|
"and will be removed in 3.0, use JSON.unsafe_load or explicitly " \
|
94
93
|
"pass `create_additions: true`"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
95
97
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
if RUBY_VERSION >= "3.0"
|
106
|
-
warn(message, uplevel: uplevel - 1, category: :deprecated)
|
98
|
+
class << self
|
99
|
+
def deprecation_warning(message, uplevel = 3) # :nodoc:
|
100
|
+
gem_root = File.expand_path("..", __dir__) + "/"
|
101
|
+
caller_locations(uplevel, 10).each do |frame|
|
102
|
+
if frame.path.nil? || frame.path.start_with?(gem_root) || frame.path.end_with?("/truffle/cext_ruby.rb", ".c")
|
103
|
+
uplevel += 1
|
107
104
|
else
|
108
|
-
|
105
|
+
break
|
109
106
|
end
|
110
107
|
end
|
108
|
+
|
109
|
+
if RUBY_VERSION >= "3.0"
|
110
|
+
warn(message, uplevel: uplevel, category: :deprecated)
|
111
|
+
else
|
112
|
+
warn(message, uplevel: uplevel)
|
113
|
+
end
|
111
114
|
end
|
112
|
-
end
|
113
115
|
|
114
|
-
class << self
|
115
116
|
# :call-seq:
|
116
117
|
# JSON[object] -> new_array or new_string
|
117
118
|
#
|
@@ -185,6 +186,25 @@ module JSON
|
|
185
186
|
|
186
187
|
private
|
187
188
|
|
189
|
+
# Called from the extension when a hash has both string and symbol keys
|
190
|
+
def on_mixed_keys_hash(hash, do_raise)
|
191
|
+
set = {}
|
192
|
+
hash.each_key do |key|
|
193
|
+
key_str = key.to_s
|
194
|
+
|
195
|
+
if set[key_str]
|
196
|
+
message = "detected duplicate key #{key_str.inspect} in #{hash.inspect}"
|
197
|
+
if do_raise
|
198
|
+
raise GeneratorError, message
|
199
|
+
else
|
200
|
+
deprecation_warning("#{message}.\nThis will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`")
|
201
|
+
end
|
202
|
+
else
|
203
|
+
set[key_str] = true
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
188
208
|
def deprecated_singleton_attr_accessor(*attrs)
|
189
209
|
args = RUBY_VERSION >= "3.0" ? ", category: :deprecated" : ""
|
190
210
|
attrs.each do |attr|
|
@@ -390,7 +410,7 @@ module JSON
|
|
390
410
|
#
|
391
411
|
# Returns a \String containing the generated \JSON data.
|
392
412
|
#
|
393
|
-
# See also JSON.
|
413
|
+
# See also JSON.pretty_generate.
|
394
414
|
#
|
395
415
|
# Argument +obj+ is the Ruby object to be converted to \JSON.
|
396
416
|
#
|
@@ -642,6 +662,7 @@ module JSON
|
|
642
662
|
# when Array
|
643
663
|
# obj.map! {|v| deserialize_obj v }
|
644
664
|
# end
|
665
|
+
# obj
|
645
666
|
# })
|
646
667
|
# pp ruby
|
647
668
|
# Output:
|
@@ -683,9 +704,13 @@ module JSON
|
|
683
704
|
if opts[:allow_blank] && (source.nil? || source.empty?)
|
684
705
|
source = 'null'
|
685
706
|
end
|
686
|
-
|
687
|
-
|
688
|
-
|
707
|
+
|
708
|
+
if proc
|
709
|
+
opts = opts.dup
|
710
|
+
opts[:on_load] = proc.to_proc
|
711
|
+
end
|
712
|
+
|
713
|
+
parse(source, opts)
|
689
714
|
end
|
690
715
|
|
691
716
|
# :call-seq:
|
@@ -802,6 +827,7 @@ module JSON
|
|
802
827
|
# when Array
|
803
828
|
# obj.map! {|v| deserialize_obj v }
|
804
829
|
# end
|
830
|
+
# obj
|
805
831
|
# })
|
806
832
|
# pp ruby
|
807
833
|
# Output:
|
@@ -1001,7 +1027,7 @@ module JSON
|
|
1001
1027
|
# See {Parsing Options}[#module-JSON-label-Parsing+Options], and {Generating Options}[#module-JSON-label-Generating+Options].
|
1002
1028
|
#
|
1003
1029
|
# For generation, the <tt>strict: true</tt> option is always set. When a Ruby object with no native \JSON counterpart is
|
1004
|
-
#
|
1030
|
+
# encountered, the block provided to the initialize method is invoked, and must return a Ruby object that has a native
|
1005
1031
|
# \JSON counterpart:
|
1006
1032
|
#
|
1007
1033
|
# module MyApp
|
@@ -8,20 +8,8 @@ module JSON
|
|
8
8
|
#
|
9
9
|
# Instantiates a new State object, configured by _opts_.
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# * *indent*: a string used to indent levels (default: ''),
|
14
|
-
# * *space*: a string that is put after, a : or , delimiter (default: ''),
|
15
|
-
# * *space_before*: a string that is put before a : pair delimiter (default: ''),
|
16
|
-
# * *object_nl*: a string that is put at the end of a JSON object (default: ''),
|
17
|
-
# * *array_nl*: a string that is put at the end of a JSON array (default: ''),
|
18
|
-
# * *allow_nan*: true if NaN, Infinity, and -Infinity should be
|
19
|
-
# generated, otherwise an exception is thrown, if these values are
|
20
|
-
# encountered. This options defaults to false.
|
21
|
-
# * *ascii_only*: true if only ASCII characters should be generated. This
|
22
|
-
# option defaults to false.
|
23
|
-
# * *buffer_initial_length*: sets the initial length of the generator's
|
24
|
-
# internal buffer.
|
11
|
+
# Argument +opts+, if given, contains a \Hash of options for the generation.
|
12
|
+
# See {Generating Options}[#module-JSON-label-Generating+Options].
|
25
13
|
def initialize(opts = nil)
|
26
14
|
if opts && !opts.empty?
|
27
15
|
configure(opts)
|
@@ -68,6 +56,11 @@ module JSON
|
|
68
56
|
buffer_initial_length: buffer_initial_length,
|
69
57
|
}
|
70
58
|
|
59
|
+
allow_duplicate_key = allow_duplicate_key?
|
60
|
+
unless allow_duplicate_key.nil?
|
61
|
+
result[:allow_duplicate_key] = allow_duplicate_key
|
62
|
+
end
|
63
|
+
|
71
64
|
instance_variables.each do |iv|
|
72
65
|
iv = iv.to_s[1..-1]
|
73
66
|
result[iv.to_sym] = self[iv]
|
data/lib/json/ext/generator.jar
CHANGED
Binary file
|
data/lib/json/ext/parser.jar
CHANGED
Binary file
|
data/lib/json/generic_object.rb
CHANGED
@@ -52,14 +52,6 @@ module JSON
|
|
52
52
|
table
|
53
53
|
end
|
54
54
|
|
55
|
-
def [](name)
|
56
|
-
__send__(name)
|
57
|
-
end unless method_defined?(:[])
|
58
|
-
|
59
|
-
def []=(name, value)
|
60
|
-
__send__("#{name}=", value)
|
61
|
-
end unless method_defined?(:[]=)
|
62
|
-
|
63
55
|
def |(other)
|
64
56
|
self.class[other.to_hash.merge(to_hash)]
|
65
57
|
end
|
@@ -271,6 +271,12 @@ module JSON
|
|
271
271
|
false
|
272
272
|
end
|
273
273
|
|
274
|
+
if opts.key?(:allow_duplicate_key)
|
275
|
+
@allow_duplicate_key = !!opts[:allow_duplicate_key]
|
276
|
+
else
|
277
|
+
@allow_duplicate_key = nil # nil is deprecation
|
278
|
+
end
|
279
|
+
|
274
280
|
@strict = !!opts[:strict] if opts.key?(:strict)
|
275
281
|
|
276
282
|
if !opts.key?(:max_nesting) # defaults to 100
|
@@ -284,6 +290,10 @@ module JSON
|
|
284
290
|
end
|
285
291
|
alias merge configure
|
286
292
|
|
293
|
+
def allow_duplicate_key? # :nodoc:
|
294
|
+
@allow_duplicate_key
|
295
|
+
end
|
296
|
+
|
287
297
|
# Returns the configuration instance variables as a hash, that can be
|
288
298
|
# passed to the configure method.
|
289
299
|
def to_h
|
@@ -292,6 +302,11 @@ module JSON
|
|
292
302
|
iv = iv.to_s[1..-1]
|
293
303
|
result[iv.to_sym] = self[iv]
|
294
304
|
end
|
305
|
+
|
306
|
+
if result[:allow_duplicate_key].nil?
|
307
|
+
result.delete(:allow_duplicate_key)
|
308
|
+
end
|
309
|
+
|
295
310
|
result
|
296
311
|
end
|
297
312
|
|
@@ -330,8 +345,17 @@ module JSON
|
|
330
345
|
when Hash
|
331
346
|
buf << '{'
|
332
347
|
first = true
|
348
|
+
key_type = nil
|
333
349
|
obj.each_pair do |k,v|
|
334
|
-
|
350
|
+
if first
|
351
|
+
key_type = k.class
|
352
|
+
else
|
353
|
+
if key_type && !@allow_duplicate_key && key_type != k.class
|
354
|
+
key_type = nil # stop checking
|
355
|
+
JSON.send(:on_mixed_keys_hash, obj, !@allow_duplicate_key.nil?)
|
356
|
+
end
|
357
|
+
buf << ','
|
358
|
+
end
|
335
359
|
|
336
360
|
key_str = k.to_s
|
337
361
|
if key_str.class == String
|
@@ -471,11 +495,30 @@ module JSON
|
|
471
495
|
delim = ",#{state.object_nl}"
|
472
496
|
result = +"{#{state.object_nl}"
|
473
497
|
first = true
|
498
|
+
key_type = nil
|
474
499
|
indent = !state.object_nl.empty?
|
475
500
|
each { |key, value|
|
476
|
-
|
501
|
+
if first
|
502
|
+
key_type = key.class
|
503
|
+
else
|
504
|
+
if key_type && !state.allow_duplicate_key? && key_type != key.class
|
505
|
+
key_type = nil # stop checking
|
506
|
+
JSON.send(:on_mixed_keys_hash, self, state.allow_duplicate_key? == false)
|
507
|
+
end
|
508
|
+
result << delim
|
509
|
+
end
|
477
510
|
result << state.indent * depth if indent
|
478
511
|
|
512
|
+
if state.strict? && !(Symbol === key || String === key)
|
513
|
+
if state.as_json
|
514
|
+
key = state.as_json.call(key)
|
515
|
+
end
|
516
|
+
|
517
|
+
unless Symbol === key || String === key
|
518
|
+
raise GeneratorError.new("#{key.class} not allowed as object key in JSON", value)
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
479
522
|
key_str = key.to_s
|
480
523
|
if key_str.is_a?(String)
|
481
524
|
key_json = key_str.to_json(state)
|
@@ -635,39 +678,6 @@ module JSON
|
|
635
678
|
rescue Encoding::UndefinedConversionError => error
|
636
679
|
raise ::JSON::GeneratorError.new(error.message, self)
|
637
680
|
end
|
638
|
-
|
639
|
-
# Module that holds the extending methods if, the String module is
|
640
|
-
# included.
|
641
|
-
module Extend
|
642
|
-
# Raw Strings are JSON Objects (the raw bytes are stored in an
|
643
|
-
# array for the key "raw"). The Ruby String can be created by this
|
644
|
-
# module method.
|
645
|
-
def json_create(o)
|
646
|
-
o['raw'].pack('C*')
|
647
|
-
end
|
648
|
-
end
|
649
|
-
|
650
|
-
# Extends _modul_ with the String::Extend module.
|
651
|
-
def self.included(modul)
|
652
|
-
modul.extend Extend
|
653
|
-
end
|
654
|
-
|
655
|
-
# This method creates a raw object hash, that can be nested into
|
656
|
-
# other data structures and will be unparsed as a raw string. This
|
657
|
-
# method should be used, if you want to convert raw strings to JSON
|
658
|
-
# instead of UTF-8 strings, e. g. binary data.
|
659
|
-
def to_json_raw_object
|
660
|
-
{
|
661
|
-
JSON.create_id => self.class.name,
|
662
|
-
'raw' => self.unpack('C*'),
|
663
|
-
}
|
664
|
-
end
|
665
|
-
|
666
|
-
# This method creates a JSON text from the result of
|
667
|
-
# a call to to_json_raw_object of this String.
|
668
|
-
def to_json_raw(*args)
|
669
|
-
to_json_raw_object.to_json(*args)
|
670
|
-
end
|
671
681
|
end
|
672
682
|
|
673
683
|
module TrueClass
|
data/lib/json/version.rb
CHANGED
data/lib/json.rb
CHANGED
@@ -133,7 +133,7 @@ require 'json/common'
|
|
133
133
|
# When not specified:
|
134
134
|
# # The last value is used and a deprecation warning emitted.
|
135
135
|
# JSON.parse('{"a": 1, "a":2}') => {"a" => 2}
|
136
|
-
# #
|
136
|
+
# # warning: detected duplicate keys in JSON object.
|
137
137
|
# # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
|
138
138
|
#
|
139
139
|
# When set to `+true+`
|
@@ -307,6 +307,25 @@ require 'json/common'
|
|
307
307
|
#
|
308
308
|
# ---
|
309
309
|
#
|
310
|
+
# Option +allow_duplicate_key+ (boolean) specifies whether
|
311
|
+
# hashes with duplicate keys should be allowed or produce an error.
|
312
|
+
# defaults to emit a deprecation warning.
|
313
|
+
#
|
314
|
+
# With the default, (not set):
|
315
|
+
# Warning[:deprecated] = true
|
316
|
+
# JSON.generate({ foo: 1, "foo" => 2 })
|
317
|
+
# # warning: detected duplicate key "foo" in {foo: 1, "foo" => 2}.
|
318
|
+
# # This will raise an error in json 3.0 unless enabled via `allow_duplicate_key: true`
|
319
|
+
# # => '{"foo":1,"foo":2}'
|
320
|
+
#
|
321
|
+
# With <tt>false</tt>
|
322
|
+
# JSON.generate({ foo: 1, "foo" => 2 }, allow_duplicate_key: false)
|
323
|
+
# # detected duplicate key "foo" in {foo: 1, "foo" => 2} (JSON::GeneratorError)
|
324
|
+
#
|
325
|
+
# In version 3.0, <tt>false</tt> will become the default.
|
326
|
+
#
|
327
|
+
# ---
|
328
|
+
#
|
310
329
|
# Option +max_nesting+ (\Integer) specifies the maximum nesting depth
|
311
330
|
# in +obj+; defaults to +100+.
|
312
331
|
#
|
@@ -384,6 +403,9 @@ require 'json/common'
|
|
384
403
|
#
|
385
404
|
# == \JSON Additions
|
386
405
|
#
|
406
|
+
# Note that JSON Additions must only be used with trusted data, and is
|
407
|
+
# deprecated.
|
408
|
+
#
|
387
409
|
# When you "round trip" a non-\String object from Ruby to \JSON and back,
|
388
410
|
# you have a new \String, instead of the object you began with:
|
389
411
|
# ruby0 = Range.new(0, 2)
|
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.
|
4
|
+
version: 2.14.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-
|
11
|
+
date: 2025-09-18 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
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/json/add/rational.rb
|
36
36
|
- lib/json/add/regexp.rb
|
37
37
|
- lib/json/add/set.rb
|
38
|
+
- lib/json/add/string.rb
|
38
39
|
- lib/json/add/struct.rb
|
39
40
|
- lib/json/add/symbol.rb
|
40
41
|
- lib/json/add/time.rb
|