json 2.7.2 → 2.9.1

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: 1ae811d90e98bbf8438c5abff24a9eabd5ef9c929115c14d3616a0c23f3a3fa2
4
- data.tar.gz: eaa6afeb5ed814f5272bf54172b98ab217b26f850cb91d6fb081a9551237030c
3
+ metadata.gz: 8404bbc1f96ebfb471ebafc0fadef1f11125cd62c6cf1157091793183a8bdc32
4
+ data.tar.gz: 4c93c85a2575eda3308cf404f116d8e638605d884fb14cd3ab3ee511b649c211
5
5
  SHA512:
6
- metadata.gz: c4119c5fdb66b553ee50cab0185cdec0ff7b09f102cfec8faa28efe2a6042d1e5cb46ada853afdc47b76707b5b180e0f68fb039e08e329935434716e2419b8e1
7
- data.tar.gz: f7d69e1e729e4b37687358bd6ebf81e8909fe4418bfff5c8a2d676b070d6af979146d0b18c01820d5bd4a7f567a62cbb90d0e164e96d05c0e99d9968657467c0
6
+ metadata.gz: 2043b99c8ca617249d1b3c81d899ebaf86dc2436196f08b0f9a32ee3ba7fa174c20124ca0f75157828049dc71f46fcd8937978cf463f952b2f2e6af113dfab42
7
+ data.tar.gz: bccae4170d82569a9018ef7497bfb5b228a9371e7c79d84cb4fcc7659be144e3a3ba455db40ecf509a31b576f311d1ad4f85989aea549f59c003210adf87fc77
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,75 @@
1
1
  # Changes
2
2
 
3
+ ### 2024-12-18 (2.9.1)
4
+
5
+ * Fix support for Solaris 10.
6
+
7
+ ### 2024-12-03 (2.9.0)
8
+
9
+ * Fix C implementation of `script_safe` escaping to not confuse some other 3 wide characters with `\u2028` and `\u2029`.
10
+ e.g. `JSON.generate(["倩", "瀨"], script_safe: true)` would generate the wrong JSON.
11
+ * `JSON.dump(object, some_io)` now write into the IO in chunks while previously it would buffer the entire JSON before writing.
12
+ * `JSON::GeneratorError` now has a `#invalid_object` attribute, making it easier to understand why an object tree cannot be serialized.
13
+ * Numerous improvements to the JRuby extension.
14
+
15
+ ### 2024-11-14 (2.8.2)
16
+
17
+ * `JSON.load_file` explictly read the file as UTF-8.
18
+
19
+ ### 2024-11-06 (2.8.1)
20
+
21
+ * Fix the java packages to include the extension.
22
+
23
+ ### 2024-11-06 (2.8.0)
24
+
25
+ * Emit a deprecation warning when `JSON.load` create custom types without the `create_additions` option being explictly enabled.
26
+ * Prefer to use `JSON.unsafe_load(string)` or `JSON.load(string, create_additions: true)`.
27
+ * Emit a deprecation warning when serializing valid UTF-8 strings encoded in `ASCII_8BIT` aka `BINARY`.
28
+ * Bump required Ruby version to 2.7.
29
+ * Add support for optionally parsing trailing commas, via `allow_trailing_comma: true`, which in cunjunction with the
30
+ pre-existing support for comments, make it suitable to parse `jsonc` documents.
31
+ * Many performance improvements to `JSON.parse` and `JSON.load`, up to `1.7x` faster on real world documents.
32
+ * Some minor performance improvements to `JSON.dump` and `JSON.generate`.
33
+ * `JSON.pretty_generate` no longer include newline inside empty object and arrays.
34
+
35
+ ### 2024-11-04 (2.7.6)
36
+
37
+ * Fix a regression in JSON.generate when dealing with Hash keys that are string subclasses, call `to_json` on them.
38
+
39
+ ### 2024-10-25 (2.7.5)
40
+
41
+ * Fix a memory leak when `#to_json` methods raise an exception.
42
+ * Gracefully handle formatting configs being set to `nil` instead of `""`.
43
+ * Workaround another issue caused by conflicting versions of both `json_pure` and `json` being loaded.
44
+
45
+ ### 2024-10-25 (2.7.4)
46
+
47
+ * Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490.
48
+ This bug would cause some gems with native extension to fail during compilation.
49
+ * Workaround different versions of `json` and `json_pure` being loaded (not officially supported).
50
+ * Make `json_pure` Ractor compatible.
51
+
52
+ ### 2024-10-24 (2.7.3)
53
+
54
+ * Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
55
+ * Limit the size of ParserError exception messages, only include up to 32 bytes of the unparseable source.
56
+ * Fix json-pure's `Object#to_json` to accept non state arguments
57
+ * Fix multiline comment support in `json-pure`.
58
+ * Fix `JSON.parse` to no longer mutate the argument encoding when passed an ASCII-8BIT string.
59
+ * Fix `String#to_json` to raise on invalid encoding in `json-pure`.
60
+ * Delete code that was based on CVTUTF.
61
+ * Use the pure-Ruby generator on TruffleRuby.
62
+ * Fix `strict` mode in `json-pure` to not break on Integer.
63
+
64
+ ### 2024-04-04 (2.7.2)
65
+
66
+ * Use rb_sym2str instead of SYM2ID #561
67
+ * Fix memory leak when exception is raised during JSON generation #574
68
+ * Remove references to "19" methods in JRuby #576
69
+ * Make OpenStruct support as optional by @hsbt in #565
70
+ * Autoload JSON::GenericObject to avoid require ostruct warning in Ruby 3.4 #577
71
+ * Warn to install ostruct if json couldn't load it by @hsbt #578
72
+
3
73
  ### 2023-12-05 (2.7.1)
4
74
 
5
75
  * JSON.dump: handle unenclosed hashes regression #554
@@ -168,7 +238,7 @@
168
238
  * Remove Rubinius exception since transcoding should be working now.
169
239
 
170
240
  ## 2013-05-13 (1.8.0)
171
- * Fix https://github.com/flori/json/issues/162 reported by Marc-Andre
241
+ * Fix https://github.com/ruby/json/issues/162 reported by Marc-Andre
172
242
  Lafortune <github_rocks@marc-andre.ca>. Thanks!
173
243
  * Applied patches by Yui NARUSE <naruse@airemix.jp> to suppress warning with
174
244
  -Wchar-subscripts and better validate UTF-8 strings.
@@ -188,7 +258,7 @@
188
258
  JSON::GenericObject.json_creatable = true
189
259
  as well.
190
260
  * Remove useless assert in fbuffer implementation.
191
- * Apply patch attached to https://github.com/flori/json/issues#issue/155
261
+ * Apply patch attached to https://github.com/ruby/json/issues#issue/155
192
262
  provided by John Shahid <jvshahid@gmail.com>, Thx!
193
263
  * Add license information to rubygems spec data, reported by Jordi Massaguer Pla <jmassaguerpla@suse.de>.
194
264
  * Improve documentation, thx to Zachary Scott <zachary@zacharyscott.net>.
@@ -202,7 +272,7 @@
202
272
  * Fix compilation of extension on older rubies.
203
273
 
204
274
  ## 2012-07-26 (1.7.4)
205
- * Fix compilation problem on AIX, see https://github.com/flori/json/issues/142
275
+ * Fix compilation problem on AIX, see https://github.com/ruby/json/issues/142
206
276
 
207
277
  ## 2012-05-12 (1.7.3)
208
278
  * Work around Rubinius encoding issues using iconv for conversion instead.
@@ -224,9 +294,9 @@
224
294
  * Propagate src encoding to values made from it (fixes 1.9 mode converting
225
295
  everything to ascii-8bit; harmless for 1.8 mode too) (Thomas E. Enebo
226
296
  <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
297
+ https://github.com/ruby/json/issues#issue/119.
298
+ * Fix https://github.com/ruby/json/issues#issue/124 Thx to Jason Hutchens.
299
+ * Fix https://github.com/ruby/json/issues#issue/117
230
300
 
231
301
  ## 2012-01-15 (1.6.5)
232
302
  * Vit Ondruch <v.ondruch@tiscali.cz> reported a bug that shows up when using
@@ -253,7 +323,7 @@
253
323
  patch go to Josh Partlow (jpartlow@github).
254
324
  * Improve parsing speed for JSON numbers (integers and floats) in a similar way to
255
325
  what Evan Phoenix <evan@phx.io> suggested in:
256
- https://github.com/flori/json/pull/103
326
+ https://github.com/ruby/json/pull/103
257
327
 
258
328
  ## 2011-09-18 (1.6.1)
259
329
  * Using -target 1.5 to force Java bits to compile with 1.5.
@@ -266,15 +336,14 @@
266
336
  * Fix memory leak when used from multiple JRuby. (Patch by
267
337
  jfirebaugh@github).
268
338
  * Apply patch by Eric Wong <nocode@yhbt.net> that fixes garbage collection problem
269
- reported in https://github.com/flori/json/issues/46.
339
+ reported in https://github.com/ruby/json/issues/46.
270
340
  * Add :quirks_mode option to parser and generator.
271
341
  * Add support for Rational and Complex number additions via json/add/complex
272
342
  and json/add/rational requires.
273
343
 
274
344
  ## 2011-06-20 (1.5.3)
275
345
  * 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.
346
+ * Add `as_json` methods in json/add/core, so rails can create its json objects the new way.
278
347
 
279
348
  ## 2011-05-11 (1.5.2)
280
349
  * Apply documentation patch by Cory Monty <cory.monty@gmail.com>.
@@ -285,7 +354,7 @@
285
354
 
286
355
  ## 2011-01-24 (1.5.1)
287
356
  * Made rake-compiler build a fat binary gem. This should fix issue
288
- https://github.com/flori/json/issues#issue/54.
357
+ https://github.com/ruby/json/issues#issue/54.
289
358
 
290
359
  ## 2011-01-22 (1.5.0)
291
360
  * Included Java source codes for the Jruby extension made by Daniel Luz
@@ -295,7 +364,7 @@
295
364
  reported by Riley Goodside.
296
365
 
297
366
  ## 2010-08-09 (1.4.6)
298
- * Fixed oversight reported in http://github.com/flori/json/issues/closed#issue/23,
367
+ * Fixed oversight reported in http://github.com/ruby/json/issues/closed#issue/23,
299
368
  always create a new object from the state prototype.
300
369
  * Made pure and ext api more similar again.
301
370
 
@@ -305,12 +374,12 @@
305
374
  argument.
306
375
  * Some fixes in the state objects and additional tests.
307
376
  ## 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
377
+ * Fixes build problem for rubinius under OS X, http://github.com/ruby/json/issues/closed#issue/25
378
+ * Fixes crashes described in http://github.com/ruby/json/issues/closed#issue/21 and
379
+ http://github.com/ruby/json/issues/closed#issue/23
311
380
  ## 2010-05-05 (1.4.3)
312
381
  * 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
382
+ * Fixed issue http://github.com/ruby/json/issues/#issue/20 reported by
314
383
  electronicwhisper@github. Thx!
315
384
 
316
385
  ## 2010-04-26 (1.4.2)
@@ -332,7 +401,7 @@
332
401
  * Extension should at least be compatible with MRI, YARV and Rubinius.
333
402
 
334
403
  ## 2010-04-07 (1.2.4)
335
- * Triger const_missing callback to make Rails' dynamic class loading work.
404
+ * Trigger const_missing callback to make Rails' dynamic class loading work.
336
405
 
337
406
  ## 2010-03-11 (1.2.3)
338
407
  * 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