json 2.6.3 → 2.13.0

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/BSDL +22 -0
  3. data/CHANGES.md +212 -17
  4. data/LEGAL +8 -0
  5. data/README.md +75 -219
  6. data/ext/json/ext/fbuffer/fbuffer.h +178 -95
  7. data/ext/json/ext/generator/extconf.rb +14 -2
  8. data/ext/json/ext/generator/generator.c +1336 -805
  9. data/ext/json/ext/parser/extconf.rb +8 -25
  10. data/ext/json/ext/parser/parser.c +1365 -3205
  11. data/ext/json/ext/simd/conf.rb +20 -0
  12. data/ext/json/ext/simd/simd.h +187 -0
  13. data/ext/json/ext/vendor/fpconv.c +479 -0
  14. data/ext/json/ext/vendor/jeaiii-ltoa.h +267 -0
  15. data/json.gemspec +48 -53
  16. data/lib/json/add/bigdecimal.rb +39 -10
  17. data/lib/json/add/complex.rb +29 -6
  18. data/lib/json/add/core.rb +1 -1
  19. data/lib/json/add/date.rb +27 -7
  20. data/lib/json/add/date_time.rb +26 -9
  21. data/lib/json/add/exception.rb +25 -7
  22. data/lib/json/add/ostruct.rb +32 -9
  23. data/lib/json/add/range.rb +33 -8
  24. data/lib/json/add/rational.rb +28 -6
  25. data/lib/json/add/regexp.rb +26 -8
  26. data/lib/json/add/set.rb +25 -6
  27. data/lib/json/add/struct.rb +29 -7
  28. data/lib/json/add/symbol.rb +34 -7
  29. data/lib/json/add/time.rb +29 -15
  30. data/lib/json/common.rb +654 -253
  31. data/lib/json/ext/generator/state.rb +106 -0
  32. data/lib/json/ext.rb +35 -5
  33. data/lib/json/generic_object.rb +7 -3
  34. data/lib/json/truffle_ruby/generator.rb +690 -0
  35. data/lib/json/version.rb +3 -7
  36. data/lib/json.rb +58 -21
  37. metadata +19 -26
  38. data/VERSION +0 -1
  39. data/ext/json/ext/generator/depend +0 -1
  40. data/ext/json/ext/generator/generator.h +0 -174
  41. data/ext/json/ext/parser/depend +0 -1
  42. data/ext/json/ext/parser/parser.h +0 -96
  43. data/ext/json/ext/parser/parser.rl +0 -986
  44. data/ext/json/extconf.rb +0 -3
  45. data/lib/json/pure/generator.rb +0 -479
  46. data/lib/json/pure/parser.rb +0 -337
  47. data/lib/json/pure.rb +0 -15
  48. /data/{LICENSE → COPYING} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc2f560520b0ab901bb8e064664fc74f0c818947048be8519ec8828c14573009
4
- data.tar.gz: 91463f0e0c677b0f431780da2362324a00d3f51baf7ea77485636dee2b400c6b
3
+ metadata.gz: 41dcbe399cb5dd00e62d93c87f31b356674c1feb9430306902009ebf8f56bd9a
4
+ data.tar.gz: f398e819143dc90c162474b5c97241d7a8c8c8209d5a5512c1b081d72a29192a
5
5
  SHA512:
6
- metadata.gz: 6eea451caa191ebe5a93de37238799d2b04ce0657f23a1098243c996a1d5047322c276241c0adb8ffe60cdd8436d46488edcd7aaebb8e2065c7406b387a4b553
7
- data.tar.gz: d5cd65f836be70cc02c078589c20c98a85995d75f71a6d02be7bedb5a43d7bc02538859f7fe621eedbe2112a29dc8bc57f995a51c336cc36b85b53a38f82becb
6
+ metadata.gz: ff828416dfb1f4a6ffcb51e02827d948b6c566ce008799cc9a02afb538b8d9a32ff1d6eee5c4e0e609757d1e9cfe1332ea359049a3fd820b199bdc7931a2573e
7
+ data.tar.gz: e5ea4c5bd447d2ed5c37b144219cd0cbed1474a5c7976f63b938996687cfc7f422e4e147582e6fee0a2d3f4ba09937496c23f08c42e2a525744a9246bcfcb5df
data/BSDL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/CHANGES.md CHANGED
@@ -1,5 +1,188 @@
1
1
  # Changes
2
2
 
3
+ ### Unreleased
4
+
5
+ ### 2025-05-23 (2.13.0)
6
+
7
+ * Add new `allow_duplicate_key` parsing options. By default a warning is now emitted when a duplicated key is encountered.
8
+ In `json 3.0` an error will be raised.
9
+ * Optimize parsing further using SIMD to scan strings.
10
+
11
+ ### 2025-05-23 (2.12.2)
12
+
13
+ * Fix compiler optimization level.
14
+
15
+ ### 2025-05-23 (2.12.1)
16
+
17
+ * Fix a potential crash in large negative floating point number generation.
18
+ * Fix for JSON.pretty_generate to use passed state object's generate instead of state class as the required parameters aren't available.
19
+
20
+ ### 2025-05-12 (2.12.0)
21
+
22
+ * Improve floating point generation to not use scientific notation as much.
23
+ * Include line and column in parser errors. Both in the message and as exception attributes.
24
+ * Handle non-string hash keys with broken `to_s` implementations.
25
+ * `JSON.generate` now uses SSE2 (x86) or NEON (arm64) instructions when available to escape strings.
26
+
27
+ ### 2025-04-25 (2.11.3)
28
+
29
+ * Fix a regression in `JSON.pretty_generate` that could cause indentation to be off once some `#to_json` has been called.
30
+
31
+ ### 2025-04-24 (2.11.2)
32
+
33
+ * Add back `JSON::PRETTY_STATE_PROTOTYPE`. This constant was private API but is used by popular gems like `multi_json`.
34
+ It now emits a deprecation warning.
35
+
36
+ ### 2025-04-24 (2.11.1)
37
+
38
+ * Add back `JSON.restore`, `JSON.unparse`, `JSON.fast_unparse` and `JSON.pretty_unparse`.
39
+ These were deprecated 16 years ago, but never emited warnings, only undocumented, so are
40
+ still used by a few gems.
41
+
42
+ ### 2025-04-24 (2.11.0)
43
+
44
+ * Optimize Integer generation to be ~1.8x faster.
45
+ * Optimize Float generation to be ~10x faster.
46
+ * Fix `JSON.load` proc argument to substitute the parsed object with the return value.
47
+ This better match `Marshal.load` behavior.
48
+ * Deprecate `JSON.fast_generate` (it's not any faster, so pointless).
49
+ * Deprecate `JSON.load_default_options`.
50
+ * Deprecate `JSON.unsafe_load_default_options`.
51
+ * Deprecate `JSON.dump_default_options`.
52
+ * Deprecate `Kernel#j`
53
+ * Deprecate `Kernel#jj`
54
+ * Remove outdated `JSON.iconv`.
55
+ * Remove `Class#json_creatable?` monkey patch.
56
+ * Remove deprecated `JSON.restore` method.
57
+ * Remove deprecated `JSON.unparse` method.
58
+ * Remove deprecated `JSON.fast_unparse` method.
59
+ * Remove deprecated `JSON.pretty_unparse` method.
60
+ * Remove deprecated `JSON::UnparserError` constant.
61
+ * Remove outdated `JSON::MissingUnicodeSupport` constant.
62
+
63
+ ### 2025-03-12 (2.10.2)
64
+
65
+ * Fix a potential crash in the C extension parser.
66
+ * Raise a ParserError on all incomplete unicode escape sequence. This was the behavior until `2.10.0` unadvertently changed it.
67
+ * Ensure document snippets that are included in parser errors don't include truncated multibyte characters.
68
+ * Ensure parser error snippets are valid UTF-8.
69
+ * Fix `JSON::GeneratorError#detailed_message` on Ruby < 3.2
70
+
71
+ ### 2025-02-10 (2.10.1)
72
+
73
+ * Fix a compatibility issue with `MultiJson.dump(obj, pretty: true)`: `no implicit conversion of false into Proc (TypeError)`.
74
+
75
+ ### 2025-02-10 (2.10.0)
76
+
77
+ * `strict: true` now accept symbols as values. Previously they'd only be accepted as hash keys.
78
+ * The C extension Parser has been entirely reimplemented from scratch.
79
+ * Introduced `JSON::Coder` as a new API allowing to customize how non native types are serialized in a non-global way.
80
+ * Introduced `JSON::Fragment` to allow assembling cached fragments in a safe way.
81
+ * The Java implementation of the generator received many optimizations.
82
+
83
+ ### 2024-12-18 (2.9.1)
84
+
85
+ * Fix support for Solaris 10.
86
+
87
+ ### 2024-12-03 (2.9.0)
88
+
89
+ * Fix C implementation of `script_safe` escaping to not confuse some other 3 wide characters with `\u2028` and `\u2029`.
90
+ e.g. `JSON.generate(["倩", "瀨"], script_safe: true)` would generate the wrong JSON.
91
+ * `JSON.dump(object, some_io)` now write into the IO in chunks while previously it would buffer the entire JSON before writing.
92
+ * `JSON::GeneratorError` now has a `#invalid_object` attribute, making it easier to understand why an object tree cannot be serialized.
93
+ * Numerous improvements to the JRuby extension.
94
+
95
+ ### 2024-11-14 (2.8.2)
96
+
97
+ * `JSON.load_file` explictly read the file as UTF-8.
98
+
99
+ ### 2024-11-06 (2.8.1)
100
+
101
+ * Fix the java packages to include the extension.
102
+
103
+ ### 2024-11-06 (2.8.0)
104
+
105
+ * Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explictly enabled.
106
+ * Prefer to use `JSON.unsafe_load(string)` or `JSON.load(string, create_additions: true)`.
107
+ * Emit a deprecation warning when serializing valid UTF-8 strings encoded in `ASCII_8BIT` aka `BINARY`.
108
+ * Bump required Ruby version to 2.7.
109
+ * Add support for optionally parsing trailing commas, via `allow_trailing_comma: true`, which in cunjunction with the
110
+ pre-existing support for comments, make it suitable to parse `jsonc` documents.
111
+ * Many performance improvements to `JSON.parse` and `JSON.load`, up to `1.7x` faster on real world documents.
112
+ * Some minor performance improvements to `JSON.dump` and `JSON.generate`.
113
+ * `JSON.pretty_generate` no longer include newline inside empty object and arrays.
114
+
115
+ ### 2024-11-04 (2.7.6)
116
+
117
+ * Fix a regression in JSON.generate when dealing with Hash keys that are string subclasses, call `to_json` on them.
118
+
119
+ ### 2024-10-25 (2.7.5)
120
+
121
+ * Fix a memory leak when `#to_json` methods raise an exception.
122
+ * Gracefully handle formatting configs being set to `nil` instead of `""`.
123
+ * Workaround another issue caused by conflicting versions of both `json_pure` and `json` being loaded.
124
+
125
+ ### 2024-10-25 (2.7.4)
126
+
127
+ * Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490.
128
+ This bug would cause some gems with native extension to fail during compilation.
129
+ * Workaround different versions of `json` and `json_pure` being loaded (not officially supported).
130
+ * Make `json_pure` Ractor compatible.
131
+
132
+ ### 2024-10-24 (2.7.3)
133
+
134
+ * Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
135
+ * Limit the size of ParserError exception messages, only include up to 32 bytes of the unparseable source.
136
+ * Fix json-pure's `Object#to_json` to accept non state arguments
137
+ * Fix multiline comment support in `json-pure`.
138
+ * Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string.
139
+ * Fix `String#to_json` to raise on invalid encoding in `json-pure`.
140
+ * Delete code that was based on CVTUTF.
141
+ * Use the pure-Ruby generator on TruffleRuby.
142
+ * Fix `strict` mode in `json-pure` to not break on Integer.
143
+
144
+ ### 2024-04-04 (2.7.2)
145
+
146
+ * Use rb_sym2str instead of SYM2ID #561
147
+ * Fix memory leak when exception is raised during JSON generation #574
148
+ * Remove references to "19" methods in JRuby #576
149
+ * Make OpenStruct support as optional by @hsbt in #565
150
+ * Autoload JSON::GenericObject to avoid require ostruct warning in Ruby 3.4 #577
151
+ * Warn to install ostruct if json couldn't load it by @hsbt #578
152
+
153
+ ### 2023-12-05 (2.7.1)
154
+
155
+ * JSON.dump: handle unenclosed hashes regression #554
156
+ * Overload kwargs in JSON.dump #556
157
+ * [DOC] RDoc for additions #557
158
+ * Fix JSON.dump overload combination #558
159
+
160
+ ### 2023-12-01 (2.7.0)
161
+
162
+ * Add a strict option to Generator #519
163
+ * `escape_slash` option was renamed as `script_safe` and now also escape U+2028 and U+2029. `escape_slash` is now an alias of `script_safe` #525
164
+ * Remove unnecessary initialization of create_id in JSON.parse() #454
165
+ * Improvements to Hash#to_json in pure implementation generator #203
166
+ * Use ruby_xfree to free buffers #518
167
+ * Fix "unexpected token" offset for Infinity #507
168
+ * Avoid using deprecated BigDecimal.new on JRuby #546
169
+ * Removed code for Ruby 1.8 #540
170
+ * Rename JSON::ParseError to JSON:ParserError #530
171
+ * Call super in included hook #486
172
+ * JRuby requires a minimum of Java 8 #516
173
+ * Always indent even if empty #517
174
+
175
+ ### 2022-11-30 (2.6.3)
176
+
177
+ * bugfix json/pure mixing escaped with literal unicode raises Encoding::CompatibilityError #483
178
+ * Stop including the parser source __LINE__ in exceptions #470
179
+
180
+ ### 2022-11-17 (2.6.2)
181
+
182
+ * Remove unknown keyword arg from DateTime.parse #488
183
+ * Ignore java artifacts by @hsbt #489
184
+ * Fix parser bug for empty string allocation #496
185
+
3
186
  ### 2021-10-24 (2.6.1)
4
187
 
5
188
  * Restore version.rb with 2.6.1
@@ -105,6 +288,19 @@
105
288
  I changed these mentions to be consistent with the Ruby license setting in
106
289
  the gemspec files which were already correct now.
107
290
 
291
+ ## 2017-01-13 (1.8.6)
292
+ * Be compatible with ancient ruby 1.8 (maybe?)
293
+
294
+ ## 2015-09-11 (1.8.5)
295
+ * Be compatible with ruby 2.4.0
296
+ * There were still some mentions of dual GPL licensing in the source, but JSON
297
+ has just the Ruby license that itself includes an explicit dual-licensing
298
+ clause that allows covered software to be distributed under the terms of
299
+ the Simplified BSD License instead for all ruby versions >= 1.9.3. This is
300
+ however a GPL compatible license according to the Free Software Foundation.
301
+ I changed these mentions to be consistent with the Ruby license setting in
302
+ the gemspec files which were already correct now.
303
+
108
304
  ## 2015-06-01 (1.8.3)
109
305
  * Fix potential memory leak, thx to nobu.
110
306
 
@@ -122,7 +318,7 @@
122
318
  * Remove Rubinius exception since transcoding should be working now.
123
319
 
124
320
  ## 2013-05-13 (1.8.0)
125
- * Fix https://github.com/flori/json/issues/162 reported by Marc-Andre
321
+ * Fix https://github.com/ruby/json/issues/162 reported by Marc-Andre
126
322
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
127
323
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
128
324
  -Wchar-subscripts and better validate UTF-8 strings.
@@ -142,7 +338,7 @@
142
338
  JSON::GenericObject.json_creatable = true
143
339
  as well.
144
340
  * Remove useless assert in fbuffer implementation.
145
- * Apply patch attached to https://github.com/flori/json/issues#issue/155
341
+ * Apply patch attached to https://github.com/ruby/json/issues#issue/155
146
342
  provided by John Shahid <jvshahid@gmail.com>, Thx!
147
343
  * Add license information to rubygems spec data, reported by Jordi Massaguer Pla <jmassaguerpla@suse.de>.
148
344
  * Improve documentation, thx to Zachary Scott <zachary@zacharyscott.net>.
@@ -156,7 +352,7 @@
156
352
  * Fix compilation of extension on older rubies.
157
353
 
158
354
  ## 2012-07-26 (1.7.4)
159
- * Fix compilation problem on AIX, see https://github.com/flori/json/issues/142
355
+ * Fix compilation problem on AIX, see https://github.com/ruby/json/issues/142
160
356
 
161
357
  ## 2012-05-12 (1.7.3)
162
358
  * Work around Rubinius encoding issues using iconv for conversion instead.
@@ -178,9 +374,9 @@
178
374
  * Propagate src encoding to values made from it (fixes 1.9 mode converting
179
375
  everything to ascii-8bit; harmless for 1.8 mode too) (Thomas E. Enebo
180
376
  <tom.enebo@gmail.com>), should fix
181
- https://github.com/flori/json/issues#issue/119.
182
- * Fix https://github.com/flori/json/issues#issue/124 Thx to Jason Hutchens.
183
- * Fix https://github.com/flori/json/issues#issue/117
377
+ https://github.com/ruby/json/issues#issue/119.
378
+ * Fix https://github.com/ruby/json/issues#issue/124 Thx to Jason Hutchens.
379
+ * Fix https://github.com/ruby/json/issues#issue/117
184
380
 
185
381
  ## 2012-01-15 (1.6.5)
186
382
  * Vit Ondruch <v.ondruch@tiscali.cz> reported a bug that shows up when using
@@ -207,7 +403,7 @@
207
403
  patch go to Josh Partlow (jpartlow@github).
208
404
  * Improve parsing speed for JSON numbers (integers and floats) in a similar way to
209
405
  what Evan Phoenix <evan@phx.io> suggested in:
210
- https://github.com/flori/json/pull/103
406
+ https://github.com/ruby/json/pull/103
211
407
 
212
408
  ## 2011-09-18 (1.6.1)
213
409
  * Using -target 1.5 to force Java bits to compile with 1.5.
@@ -220,15 +416,14 @@
220
416
  * Fix memory leak when used from multiple JRuby. (Patch by
221
417
  jfirebaugh@github).
222
418
  * Apply patch by Eric Wong <nocode@yhbt.net> that fixes garbage collection problem
223
- reported in https://github.com/flori/json/issues/46.
419
+ reported in https://github.com/ruby/json/issues/46.
224
420
  * Add :quirks_mode option to parser and generator.
225
421
  * Add support for Rational and Complex number additions via json/add/complex
226
422
  and json/add/rational requires.
227
423
 
228
424
  ## 2011-06-20 (1.5.3)
229
425
  * Alias State#configure method as State#merge to increase duck type synonymy with Hash.
230
- * Add `as_json` methods in json/add/core, so rails can create its json objects
231
- the new way.
426
+ * Add `as_json` methods in json/add/core, so rails can create its json objects the new way.
232
427
 
233
428
  ## 2011-05-11 (1.5.2)
234
429
  * Apply documentation patch by Cory Monty <cory.monty@gmail.com>.
@@ -239,7 +434,7 @@
239
434
 
240
435
  ## 2011-01-24 (1.5.1)
241
436
  * Made rake-compiler build a fat binary gem. This should fix issue
242
- https://github.com/flori/json/issues#issue/54.
437
+ https://github.com/ruby/json/issues#issue/54.
243
438
 
244
439
  ## 2011-01-22 (1.5.0)
245
440
  * Included Java source codes for the Jruby extension made by Daniel Luz
@@ -249,7 +444,7 @@
249
444
  reported by Riley Goodside.
250
445
 
251
446
  ## 2010-08-09 (1.4.6)
252
- * Fixed oversight reported in http://github.com/flori/json/issues/closed#issue/23,
447
+ * Fixed oversight reported in http://github.com/ruby/json/issues/closed#issue/23,
253
448
  always create a new object from the state prototype.
254
449
  * Made pure and ext api more similar again.
255
450
 
@@ -259,12 +454,12 @@
259
454
  argument.
260
455
  * Some fixes in the state objects and additional tests.
261
456
  ## 2010-08-06 (1.4.4)
262
- * Fixes build problem for rubinius under OS X, http://github.com/flori/json/issues/closed#issue/25
263
- * Fixes crashes described in http://github.com/flori/json/issues/closed#issue/21 and
264
- http://github.com/flori/json/issues/closed#issue/23
457
+ * Fixes build problem for rubinius under OS X, http://github.com/ruby/json/issues/closed#issue/25
458
+ * Fixes crashes described in http://github.com/ruby/json/issues/closed#issue/21 and
459
+ http://github.com/ruby/json/issues/closed#issue/23
265
460
  ## 2010-05-05 (1.4.3)
266
461
  * Fixed some test assertions, from Ruby r27587 and r27590, patch by nobu.
267
- * Fixed issue http://github.com/flori/json/issues/#issue/20 reported by
462
+ * Fixed issue http://github.com/ruby/json/issues/#issue/20 reported by
268
463
  electronicwhisper@github. Thx!
269
464
 
270
465
  ## 2010-04-26 (1.4.2)
@@ -286,7 +481,7 @@
286
481
  * Extension should at least be compatible with MRI, YARV and Rubinius.
287
482
 
288
483
  ## 2010-04-07 (1.2.4)
289
- * Triger const_missing callback to make Rails' dynamic class loading work.
484
+ * Trigger const_missing callback to make Rails' dynamic class loading work.
290
485
 
291
486
  ## 2010-03-11 (1.2.3)
292
487
  * Added a `State#[]` method which returns an attribute's value in order to
data/LEGAL ADDED
@@ -0,0 +1,8 @@
1
+ # -*- rdoc -*-
2
+
3
+ = LEGAL NOTICE INFORMATION
4
+ --------------------------
5
+
6
+ All the files in this distribution are covered under either the Ruby's
7
+ license (see the file COPYING) or public-domain except some files
8
+ mentioned below.