json 2.7.2 → 2.8.2

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: 1ae811d90e98bbf8438c5abff24a9eabd5ef9c929115c14d3616a0c23f3a3fa2
4
- data.tar.gz: eaa6afeb5ed814f5272bf54172b98ab217b26f850cb91d6fb081a9551237030c
3
+ metadata.gz: 61a5759c78160e412505a53cc6579e3259689fe69adbd74d5e4aefb21b7ef64c
4
+ data.tar.gz: 072f37b6964a498df827e85e2038e4692c8452d5365a6c8794536508b1a95e9d
5
5
  SHA512:
6
- metadata.gz: c4119c5fdb66b553ee50cab0185cdec0ff7b09f102cfec8faa28efe2a6042d1e5cb46ada853afdc47b76707b5b180e0f68fb039e08e329935434716e2419b8e1
7
- data.tar.gz: f7d69e1e729e4b37687358bd6ebf81e8909fe4418bfff5c8a2d676b070d6af979146d0b18c01820d5bd4a7f567a62cbb90d0e164e96d05c0e99d9968657467c0
6
+ metadata.gz: e65781ec7eb7ab0c5b48b12eaf8e988fd5632874d60c6c35450ba934c586ceb47b622adb5b6f2652dcd7a1641dedbb0a674d1b458839d45944c862671d74d33f
7
+ data.tar.gz: 19b1ccd3cdf1126ac3825993a3c4aa06eff96b5ab80e0391ee3a150c4dd164d53052fa89aea0aeabd53e1bfbf4f513fc5276471c7eff1231e38f1ad89f1df1d7
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,62 @@
1
1
  # Changes
2
2
 
3
+ ### 2024-11-14 (2.8.2)
4
+
5
+ * `JSON.load_file` explictly read the file as UTF-8.
6
+
7
+ ### 2024-11-06 (2.8.1)
8
+
9
+ * Fix the java packages to include the extension.
10
+
11
+ ### 2024-11-06 (2.8.0)
12
+
13
+ * Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explictly enabled.
14
+ * Prefer to use `JSON.unsafe_load(string)` or `JSON.load(string, create_additions: true)`.
15
+ * Emit a deprecation warning when serializing valid UTF-8 strings encoded in `ASCII_8BIT` aka `BINARY`.
16
+ * Bump required Ruby version to 2.7.
17
+ * Add support for optionally parsing trailing commas, via `allow_trailing_comma: true`, which in cunjunction with the
18
+ pre-existing support for comments, make it suitable to parse `jsonc` documents.
19
+ * Many performance improvements to `JSON.parse` and `JSON.load`, up to `1.7x` faster on real world documents.
20
+ * Some minor performance improvements to `JSON.dump` and `JSON.generate`.
21
+
22
+ ### 2024-11-04 (2.7.6)
23
+
24
+ * Fix a regression in JSON.generate when dealing with Hash keys that are string subclasses, call `to_json` on them.
25
+
26
+ ### 2024-10-25 (2.7.5)
27
+
28
+ * Fix a memory leak when `#to_json` methods raise an exception.
29
+ * Gracefully handle formatting configs being set to `nil` instead of `""`.
30
+ * Workaround another issue caused by conflicting versions of both `json_pure` and `json` being loaded.
31
+
32
+ ### 2024-10-25 (2.7.4)
33
+
34
+ * Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490.
35
+ This bug would cause some gems with native extension to fail during compilation.
36
+ * Workaround different versions of `json` and `json_pure` being loaded (not officially supported).
37
+ * Make `json_pure` Ractor compatible.
38
+
39
+ ### 2024-10-24 (2.7.3)
40
+
41
+ * Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
42
+ * Limit the size of ParserError exception messages, only include up to 32 bytes of the unparseable source.
43
+ * Fix json-pure's `Object#to_json` to accept non state arguments
44
+ * Fix multiline comment support in `json-pure`.
45
+ * Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string.
46
+ * Fix `String#to_json` to raise on invalid encoding in `json-pure`.
47
+ * Delete code that was based on CVTUTF.
48
+ * Use the pure-Ruby generator on TruffleRuby.
49
+ * Fix `strict` mode in `json-pure` to not break on Integer.
50
+
51
+ ### 2024-04-04 (2.7.2)
52
+
53
+ * Use rb_sym2str instead of SYM2ID #561
54
+ * Fix memory leak when exception is raised during JSON generation #574
55
+ * Remove references to "19" methods in JRuby #576
56
+ * Make OpenStruct support as optional by @hsbt in #565
57
+ * Autoload JSON::GenericObject to avoid require ostruct warning in Ruby 3.4 #577
58
+ * Warn to install ostruct if json couldn't load it by @hsbt #578
59
+
3
60
  ### 2023-12-05 (2.7.1)
4
61
 
5
62
  * JSON.dump: handle unenclosed hashes regression #554
@@ -168,7 +225,7 @@
168
225
  * Remove Rubinius exception since transcoding should be working now.
169
226
 
170
227
  ## 2013-05-13 (1.8.0)
171
- * Fix https://github.com/flori/json/issues/162 reported by Marc-Andre
228
+ * Fix https://github.com/ruby/json/issues/162 reported by Marc-Andre
172
229
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
173
230
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
174
231
  -Wchar-subscripts and better validate UTF-8 strings.
@@ -188,7 +245,7 @@
188
245
  JSON::GenericObject.json_creatable = true
189
246
  as well.
190
247
  * Remove useless assert in fbuffer implementation.
191
- * Apply patch attached to https://github.com/flori/json/issues#issue/155
248
+ * Apply patch attached to https://github.com/ruby/json/issues#issue/155
192
249
  provided by John Shahid <jvshahid@gmail.com>, Thx!
193
250
  * Add license information to rubygems spec data, reported by Jordi Massaguer Pla <jmassaguerpla@suse.de>.
194
251
  * Improve documentation, thx to Zachary Scott <zachary@zacharyscott.net>.
@@ -202,7 +259,7 @@
202
259
  * Fix compilation of extension on older rubies.
203
260
 
204
261
  ## 2012-07-26 (1.7.4)
205
- * Fix compilation problem on AIX, see https://github.com/flori/json/issues/142
262
+ * Fix compilation problem on AIX, see https://github.com/ruby/json/issues/142
206
263
 
207
264
  ## 2012-05-12 (1.7.3)
208
265
  * Work around Rubinius encoding issues using iconv for conversion instead.
@@ -224,9 +281,9 @@
224
281
  * Propagate src encoding to values made from it (fixes 1.9 mode converting
225
282
  everything to ascii-8bit; harmless for 1.8 mode too) (Thomas E. Enebo
226
283
  <tom.enebo@gmail.com>), should fix
227
- https://github.com/flori/json/issues#issue/119.
228
- * Fix https://github.com/flori/json/issues#issue/124 Thx to Jason Hutchens.
229
- * Fix https://github.com/flori/json/issues#issue/117
284
+ https://github.com/ruby/json/issues#issue/119.
285
+ * Fix https://github.com/ruby/json/issues#issue/124 Thx to Jason Hutchens.
286
+ * Fix https://github.com/ruby/json/issues#issue/117
230
287
 
231
288
  ## 2012-01-15 (1.6.5)
232
289
  * Vit Ondruch <v.ondruch@tiscali.cz> reported a bug that shows up when using
@@ -253,7 +310,7 @@
253
310
  patch go to Josh Partlow (jpartlow@github).
254
311
  * Improve parsing speed for JSON numbers (integers and floats) in a similar way to
255
312
  what Evan Phoenix <evan@phx.io> suggested in:
256
- https://github.com/flori/json/pull/103
313
+ https://github.com/ruby/json/pull/103
257
314
 
258
315
  ## 2011-09-18 (1.6.1)
259
316
  * Using -target 1.5 to force Java bits to compile with 1.5.
@@ -266,15 +323,14 @@
266
323
  * Fix memory leak when used from multiple JRuby. (Patch by
267
324
  jfirebaugh@github).
268
325
  * Apply patch by Eric Wong <nocode@yhbt.net> that fixes garbage collection problem
269
- reported in https://github.com/flori/json/issues/46.
326
+ reported in https://github.com/ruby/json/issues/46.
270
327
  * Add :quirks_mode option to parser and generator.
271
328
  * Add support for Rational and Complex number additions via json/add/complex
272
329
  and json/add/rational requires.
273
330
 
274
331
  ## 2011-06-20 (1.5.3)
275
332
  * Alias State#configure method as State#merge to increase duck type synonymy with Hash.
276
- * Add `as_json` methods in json/add/core, so rails can create its json objects
277
- the new way.
333
+ * Add `as_json` methods in json/add/core, so rails can create its json objects the new way.
278
334
 
279
335
  ## 2011-05-11 (1.5.2)
280
336
  * Apply documentation patch by Cory Monty <cory.monty@gmail.com>.
@@ -285,7 +341,7 @@
285
341
 
286
342
  ## 2011-01-24 (1.5.1)
287
343
  * Made rake-compiler build a fat binary gem. This should fix issue
288
- https://github.com/flori/json/issues#issue/54.
344
+ https://github.com/ruby/json/issues#issue/54.
289
345
 
290
346
  ## 2011-01-22 (1.5.0)
291
347
  * Included Java source codes for the Jruby extension made by Daniel Luz
@@ -295,7 +351,7 @@
295
351
  reported by Riley Goodside.
296
352
 
297
353
  ## 2010-08-09 (1.4.6)
298
- * Fixed oversight reported in http://github.com/flori/json/issues/closed#issue/23,
354
+ * Fixed oversight reported in http://github.com/ruby/json/issues/closed#issue/23,
299
355
  always create a new object from the state prototype.
300
356
  * Made pure and ext api more similar again.
301
357
 
@@ -305,12 +361,12 @@
305
361
  argument.
306
362
  * Some fixes in the state objects and additional tests.
307
363
  ## 2010-08-06 (1.4.4)
308
- * Fixes build problem for rubinius under OS X, http://github.com/flori/json/issues/closed#issue/25
309
- * Fixes crashes described in http://github.com/flori/json/issues/closed#issue/21 and
310
- http://github.com/flori/json/issues/closed#issue/23
364
+ * Fixes build problem for rubinius under OS X, http://github.com/ruby/json/issues/closed#issue/25
365
+ * Fixes crashes described in http://github.com/ruby/json/issues/closed#issue/21 and
366
+ http://github.com/ruby/json/issues/closed#issue/23
311
367
  ## 2010-05-05 (1.4.3)
312
368
  * Fixed some test assertions, from Ruby r27587 and r27590, patch by nobu.
313
- * Fixed issue http://github.com/flori/json/issues/#issue/20 reported by
369
+ * Fixed issue http://github.com/ruby/json/issues/#issue/20 reported by
314
370
  electronicwhisper@github. Thx!
315
371
 
316
372
  ## 2010-04-26 (1.4.2)
@@ -332,7 +388,7 @@
332
388
  * Extension should at least be compatible with MRI, YARV and Rubinius.
333
389
 
334
390
  ## 2010-04-07 (1.2.4)
335
- * Triger const_missing callback to make Rails' dynamic class loading work.
391
+ * Trigger const_missing callback to make Rails' dynamic class loading work.
336
392
 
337
393
  ## 2010-03-11 (1.2.3)
338
394
  * Added a `State#[]` method which returns an attribute's value in order to
data/LEGAL ADDED
@@ -0,0 +1,60 @@
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.
9
+
10
+ == MIT License
11
+ >>>
12
+ Permission is hereby granted, free of charge, to any person obtaining
13
+ a copy of this software and associated documentation files (the
14
+ "Software"), to deal in the Software without restriction, including
15
+ without limitation the rights to use, copy, modify, merge, publish,
16
+ distribute, sublicense, and/or sell copies of the Software, and to
17
+ permit persons to whom the Software is furnished to do so, subject to
18
+ the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be
21
+ included in all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
+
31
+ == Old-style BSD license
32
+ >>>
33
+ Redistribution and use in source and binary forms, with or without
34
+ modification, are permitted provided that the following conditions
35
+ are met:
36
+ 1. Redistributions of source code must retain the above copyright
37
+ notice, this list of conditions and the following disclaimer.
38
+ 2. Redistributions in binary form must reproduce the above copyright
39
+ notice, this list of conditions and the following disclaimer in the
40
+ documentation and/or other materials provided with the distribution.
41
+ 3. Neither the name of the University nor the names of its contributors
42
+ may be used to endorse or promote products derived from this software
43
+ without specific prior written permission.
44
+
45
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55
+ SUCH DAMAGE.
56
+
57
+ IMPORTANT NOTE::
58
+
59
+ From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
60
+ paragraph 3 above is now null and void.
data/README.md CHANGED
@@ -1,21 +1,14 @@
1
1
  # JSON implementation for Ruby
2
2
 
3
- [![CI](https://github.com/flori/json/actions/workflows/ci.yml/badge.svg)](https://github.com/flori/json/actions/workflows/ci.yml)
3
+ [![CI](https://github.com/ruby/json/actions/workflows/ci.yml/badge.svg)](https://github.com/ruby/json/actions/workflows/ci.yml)
4
4
 
5
5
  ## Description
6
6
 
7
- This is a implementation of the JSON specification according to RFC 7159
8
- http://www.ietf.org/rfc/rfc7159.txt . Starting from version 1.0.0 on there
9
- will be two variants available:
7
+ This is an implementation of the JSON specification according to RFC 7159
8
+ http://www.ietf.org/rfc/rfc7159.txt .
10
9
 
11
- * A pure ruby variant, that relies on the iconv and the stringscan
12
- extensions, which are both part of the ruby standard library.
13
- * The quite a bit faster native extension variant, which is in parts
14
- implemented in C or Java and comes with its own unicode conversion
15
- functions and a parser generated by the [Ragel] state machine compiler.
16
-
17
- Both variants of the JSON generator generate UTF-8 character sequences by
18
- default. If an :ascii\_only option with a true value is given, they escape all
10
+ The JSON generator generate UTF-8 character sequences by default.
11
+ If an :ascii\_only option with a true value is given, they escape all
19
12
  non-ASCII and control characters with \uXXXX escape sequences, and support
20
13
  UTF-16 surrogate pairs in order to be able to generate the whole range of
21
14
  unicode code points.
@@ -28,49 +21,13 @@ endpoint.
28
21
 
29
22
  ## Installation
30
23
 
31
- It's recommended to use the extension variant of JSON, because it's faster than
32
- the pure ruby variant. If you cannot build it on your system, you can settle
33
- for the latter.
34
-
35
- Just type into the command line as root:
36
-
37
- ```
38
- # rake install
39
- ```
40
-
41
- The above command will build the extensions and install them on your system.
24
+ Install the gem and add to the application's Gemfile by executing:
42
25
 
43
- ```
44
- # rake install_pure
45
- ```
26
+ $ bundle add json
46
27
 
47
- or
28
+ If bundler is not being used to manage dependencies, install the gem by executing:
48
29
 
49
- ```
50
- # ruby install.rb
51
- ```
52
-
53
- will just install the pure ruby implementation of JSON.
54
-
55
- If you use Rubygems you can type
56
-
57
- ```
58
- # gem install json
59
- ```
60
-
61
- instead, to install the newest JSON version.
62
-
63
- There is also a pure ruby json only variant of the gem, that can be installed
64
- with:
65
-
66
- ```
67
- # gem install json_pure
68
- ```
69
-
70
- ## Compiling the extensions yourself
71
-
72
- If you want to create the `parser.c` file from its `parser.rl` file or draw nice
73
- graphviz images of the state machines, you need [Ragel].
30
+ $ gem install json
74
31
 
75
32
  ## Usage
76
33
 
@@ -80,20 +37,6 @@ To use JSON you can
80
37
  require 'json'
81
38
  ```
82
39
 
83
- to load the installed variant (either the extension `'json'` or the pure
84
- variant `'json_pure'`). If you have installed the extension variant, you can
85
- pick either the extension variant or the pure variant by typing
86
-
87
- ```ruby
88
- require 'json/ext'
89
- ```
90
-
91
- or
92
-
93
- ```ruby
94
- require 'json/pure'
95
- ```
96
-
97
40
  Now you can parse a JSON document into a ruby data structure by calling
98
41
 
99
42
  ```ruby
@@ -109,50 +52,11 @@ You can also use the `pretty_generate` method (which formats the output more
109
52
  verbosely and nicely) or `fast_generate` (which doesn't do any of the security
110
53
  checks generate performs, e. g. nesting deepness checks).
111
54
 
112
- There are also the JSON and JSON[] methods which use parse on a String or
113
- generate a JSON document from an array or hash:
114
-
115
- ```ruby
116
- document = JSON 'test' => 23 # => "{\"test\":23}"
117
- document = JSON['test' => 23] # => "{\"test\":23}"
118
- ```
119
-
120
- and
121
-
122
- ```ruby
123
- data = JSON '{"test":23}' # => {"test"=>23}
124
- data = JSON['{"test":23}'] # => {"test"=>23}
125
- ```
55
+ ## Handling arbitrary types
126
56
 
127
- You can choose to load a set of common additions to ruby core's objects if
128
- you
129
-
130
- ```ruby
131
- require 'json/add/core'
132
- ```
133
-
134
- After requiring this you can, e. g., serialise/deserialise Ruby ranges:
135
-
136
- ```ruby
137
- JSON JSON(1..10) # => 1..10
138
- ```
139
-
140
- To find out how to add JSON support to other or your own classes, read the
141
- section "More Examples" below.
142
-
143
- ## Serializing exceptions
144
-
145
- The JSON module doesn't extend `Exception` by default. If you convert an `Exception`
146
- object to JSON, it will by default only include the exception message.
147
-
148
- To include the full details, you must either load the `json/add/core` mentioned
149
- above, or specifically load the exception addition:
150
-
151
- ```ruby
152
- require 'json/add/exception'
153
- ```
154
-
155
- ## More Examples
57
+ > [!CAUTION]
58
+ > You should never use `JSON.unsafe_load` nor `JSON.parse(str, create_additions: true)` to parse untrusted user input,
59
+ > as it can lead to remote code execution vulnerabilities.
156
60
 
157
61
  To create a JSON document from a ruby data structure, you can call
158
62
  `JSON.generate` like that:
@@ -218,7 +122,7 @@ JSON.parse json
218
122
  # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
219
123
  json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
220
124
  # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
221
- JSON.parse json, :create_additions => true
125
+ JSON.unsafe_load json
222
126
  # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
223
127
  ```
224
128
 
@@ -254,136 +158,11 @@ There are also the methods `Kernel#j` for generate, and `Kernel#jj` for
254
158
  `pretty_generate` output to the console, that work analogous to Core Ruby's `p` and
255
159
  the `pp` library's `pp` methods.
256
160
 
257
- The script `tools/server.rb` contains a small example if you want to test, how
258
- receiving a JSON object from a webrick server in your browser with the
259
- JavaScript prototype library http://www.prototypejs.org works.
260
-
261
- ## Speed Comparisons
262
-
263
- I have created some benchmark results (see the benchmarks/data-p4-3Ghz
264
- subdir of the package) for the JSON-parser to estimate the speed up in the C
265
- extension:
266
-
267
- ```
268
- Comparing times (call_time_mean):
269
- 1 ParserBenchmarkExt#parser 900 repeats:
270
- 553.922304770 ( real) -> 21.500x
271
- 0.001805307
272
- 2 ParserBenchmarkYAML#parser 1000 repeats:
273
- 224.513358139 ( real) -> 8.714x
274
- 0.004454078
275
- 3 ParserBenchmarkPure#parser 1000 repeats:
276
- 26.755020642 ( real) -> 1.038x
277
- 0.037376163
278
- 4 ParserBenchmarkRails#parser 1000 repeats:
279
- 25.763381731 ( real) -> 1.000x
280
- 0.038814780
281
- calls/sec ( time) -> speed covers
282
- secs/call
283
- ```
284
-
285
- In the table above 1 is `JSON::Ext::Parser`, 2 is `YAML.load` with YAML
286
- compatible JSON document, 3 is is `JSON::Pure::Parser`, and 4 is
287
- `ActiveSupport::JSON.decode`. The ActiveSupport JSON-decoder converts the
288
- input first to YAML and then uses the YAML-parser, the conversion seems to
289
- slow it down so much that it is only as fast as the `JSON::Pure::Parser`!
290
-
291
- If you look at the benchmark data you can see that this is mostly caused by
292
- the frequent high outliers - the median of the Rails-parser runs is still
293
- overall smaller than the median of the `JSON::Pure::Parser` runs:
294
-
295
- ```
296
- Comparing times (call_time_median):
297
- 1 ParserBenchmarkExt#parser 900 repeats:
298
- 800.592479481 ( real) -> 26.936x
299
- 0.001249075
300
- 2 ParserBenchmarkYAML#parser 1000 repeats:
301
- 271.002390644 ( real) -> 9.118x
302
- 0.003690004
303
- 3 ParserBenchmarkRails#parser 1000 repeats:
304
- 30.227910865 ( real) -> 1.017x
305
- 0.033082008
306
- 4 ParserBenchmarkPure#parser 1000 repeats:
307
- 29.722384421 ( real) -> 1.000x
308
- 0.033644676
309
- calls/sec ( time) -> speed covers
310
- secs/call
311
- ```
312
-
313
- I have benchmarked the `JSON-Generator` as well. This generated a few more
314
- values, because there are different modes that also influence the achieved
315
- speed:
316
-
317
- ```
318
- Comparing times (call_time_mean):
319
- 1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
320
- 547.354332608 ( real) -> 15.090x
321
- 0.001826970
322
- 2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
323
- 443.968212317 ( real) -> 12.240x
324
- 0.002252414
325
- 3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
326
- 375.104545883 ( real) -> 10.341x
327
- 0.002665923
328
- 4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
329
- 49.978706968 ( real) -> 1.378x
330
- 0.020008521
331
- 5 GeneratorBenchmarkRails#generator 1000 repeats:
332
- 38.531868759 ( real) -> 1.062x
333
- 0.025952543
334
- 6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
335
- 36.927649925 ( real) -> 1.018x 7 (>=3859)
336
- 0.027079979
337
- 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats:
338
- 36.272134441 ( real) -> 1.000x 6 (>=3859)
339
- 0.027569373
340
- calls/sec ( time) -> speed covers
341
- secs/call
342
- ```
343
-
344
- In the table above 1-3 are `JSON::Ext::Generator` methods. 4, 6, and 7 are
345
- `JSON::Pure::Generator` methods and 5 is the Rails JSON generator. It is now a
346
- bit faster than the `generator_safe` and `generator_pretty` methods of the pure
347
- variant but slower than the others.
348
-
349
- To achieve the fastest JSON document output, you can use the `fast_generate`
350
- method. Beware, that this will disable the checking for circular Ruby data
351
- structures, which may cause JSON to go into an infinite loop.
352
-
353
- Here are the median comparisons for completeness' sake:
354
-
355
- ```
356
- Comparing times (call_time_median):
357
- 1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
358
- 708.258020939 ( real) -> 16.547x
359
- 0.001411915
360
- 2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
361
- 569.105020353 ( real) -> 13.296x
362
- 0.001757145
363
- 3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
364
- 482.825371244 ( real) -> 11.280x
365
- 0.002071142
366
- 4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
367
- 62.717626652 ( real) -> 1.465x
368
- 0.015944481
369
- 5 GeneratorBenchmarkRails#generator 1000 repeats:
370
- 43.965681162 ( real) -> 1.027x
371
- 0.022745013
372
- 6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
373
- 43.929073409 ( real) -> 1.026x 7 (>=3859)
374
- 0.022763968
375
- 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats:
376
- 42.802514491 ( real) -> 1.000x 6 (>=3859)
377
- 0.023363113
378
- calls/sec ( time) -> speed covers
379
- secs/call
380
- ```
381
-
382
161
  ## Development
383
162
 
384
163
  ### Release
385
164
 
386
- Update the json.gemspec and json-java.gemspec.
165
+ Update the `lib/json/version.rb` file.
387
166
 
388
167
  ```
389
168
  rbenv shell 2.6.5