json 1.8.6 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +5 -5
  2. data/{CHANGES → CHANGES.md} +234 -95
  3. data/Gemfile +10 -3
  4. data/LICENSE +56 -0
  5. data/README.md +187 -107
  6. data/VERSION +1 -1
  7. data/ext/json/ext/fbuffer/fbuffer.h +0 -3
  8. data/ext/json/ext/generator/generator.c +227 -101
  9. data/ext/json/ext/generator/generator.h +5 -8
  10. data/ext/json/ext/parser/extconf.rb +28 -0
  11. data/ext/json/ext/parser/parser.c +420 -481
  12. data/ext/json/ext/parser/parser.h +5 -5
  13. data/ext/json/ext/parser/parser.rl +148 -172
  14. data/ext/json/extconf.rb +1 -1
  15. data/json.gemspec +0 -0
  16. data/lib/json.rb +550 -29
  17. data/lib/json/add/bigdecimal.rb +3 -2
  18. data/lib/json/add/complex.rb +4 -4
  19. data/lib/json/add/core.rb +1 -0
  20. data/lib/json/add/date.rb +1 -1
  21. data/lib/json/add/date_time.rb +1 -1
  22. data/lib/json/add/exception.rb +1 -1
  23. data/lib/json/add/ostruct.rb +3 -3
  24. data/lib/json/add/range.rb +1 -1
  25. data/lib/json/add/rational.rb +3 -3
  26. data/lib/json/add/regexp.rb +3 -3
  27. data/lib/json/add/set.rb +29 -0
  28. data/lib/json/add/struct.rb +1 -1
  29. data/lib/json/add/symbol.rb +1 -1
  30. data/lib/json/add/time.rb +1 -1
  31. data/lib/json/common.rb +381 -162
  32. data/lib/json/ext.rb +0 -6
  33. data/lib/json/generic_object.rb +5 -4
  34. data/lib/json/pure.rb +2 -8
  35. data/lib/json/pure/generator.rb +73 -124
  36. data/lib/json/pure/parser.rb +62 -84
  37. data/lib/json/version.rb +2 -1
  38. data/tests/fixtures/fail29.json +1 -0
  39. data/tests/fixtures/fail30.json +1 -0
  40. data/tests/fixtures/fail31.json +1 -0
  41. data/tests/fixtures/fail32.json +1 -0
  42. data/tests/fixtures/obsolete_fail1.json +1 -0
  43. data/tests/{test_json_addition.rb → json_addition_test.rb} +28 -25
  44. data/tests/json_common_interface_test.rb +169 -0
  45. data/tests/json_encoding_test.rb +107 -0
  46. data/tests/json_ext_parser_test.rb +15 -0
  47. data/tests/{test_json_fixtures.rb → json_fixtures_test.rb} +13 -8
  48. data/tests/{test_json_generate.rb → json_generator_test.rb} +98 -47
  49. data/tests/{test_json_generic_object.rb → json_generic_object_test.rb} +15 -8
  50. data/tests/json_parser_test.rb +497 -0
  51. data/tests/json_string_matching_test.rb +38 -0
  52. data/tests/lib/core_assertions.rb +763 -0
  53. data/tests/lib/envutil.rb +365 -0
  54. data/tests/lib/find_executable.rb +22 -0
  55. data/tests/lib/helper.rb +4 -0
  56. data/tests/ractor_test.rb +30 -0
  57. data/tests/test_helper.rb +17 -0
  58. metadata +43 -69
  59. data/.gitignore +0 -17
  60. data/.travis.yml +0 -18
  61. data/README-json-jruby.markdown +0 -33
  62. data/Rakefile +0 -402
  63. data/TODO +0 -1
  64. data/data/example.json +0 -1
  65. data/data/index.html +0 -38
  66. data/data/prototype.js +0 -4184
  67. data/diagrams/.keep +0 -0
  68. data/install.rb +0 -23
  69. data/java/src/json/ext/ByteListTranscoder.java +0 -166
  70. data/java/src/json/ext/Generator.java +0 -446
  71. data/java/src/json/ext/GeneratorMethods.java +0 -231
  72. data/java/src/json/ext/GeneratorService.java +0 -42
  73. data/java/src/json/ext/GeneratorState.java +0 -542
  74. data/java/src/json/ext/OptionsReader.java +0 -113
  75. data/java/src/json/ext/Parser.java +0 -2644
  76. data/java/src/json/ext/Parser.rl +0 -968
  77. data/java/src/json/ext/ParserService.java +0 -34
  78. data/java/src/json/ext/RuntimeInfo.java +0 -120
  79. data/java/src/json/ext/StringDecoder.java +0 -166
  80. data/java/src/json/ext/StringEncoder.java +0 -111
  81. data/java/src/json/ext/Utils.java +0 -88
  82. data/json-java.gemspec +0 -38
  83. data/json_pure.gemspec +0 -37
  84. data/tests/fixtures/fail1.json +0 -1
  85. data/tests/setup_variant.rb +0 -11
  86. data/tests/test_json.rb +0 -519
  87. data/tests/test_json_encoding.rb +0 -65
  88. data/tests/test_json_string_matching.rb +0 -39
  89. data/tests/test_json_unicode.rb +0 -72
  90. data/tools/diff.sh +0 -18
  91. data/tools/fuzz.rb +0 -139
  92. data/tools/server.rb +0 -62
data/Gemfile CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gemspec :name => 'json'
6
- gemspec :name => 'json_pure'
7
- #gemspec :name => 'json-java'
5
+ case ENV['JSON']
6
+ when 'ext', nil
7
+ if ENV['RUBY_ENGINE'] == 'jruby'
8
+ gemspec :name => 'json-java'
9
+ else
10
+ gemspec :name => 'json'
11
+ end
12
+ when 'pure'
13
+ gemspec :name => 'json_pure'
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a) distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- # JSON implementation for Ruby {<img src="https://secure.travis-ci.org/flori/json.png" />}[http://travis-ci.org/flori/json]
1
+ # JSON implementation for Ruby
2
+
3
+ [![Travis Widget](http://travis-ci.org/flori/json.svg?branch=master)](https://travis-ci.org/flori/json)
2
4
 
3
5
  ## Description
4
6
 
5
- This is a implementation of the JSON specification according to RFC 4627
6
- http://www.ietf.org/rfc/rfc4627.txt . Starting from version 1.0.0 on there
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
7
9
  will be two variants available:
8
10
 
9
11
  * A pure ruby variant, that relies on the iconv and the stringscan
@@ -25,13 +27,6 @@ encoded, please use the to\_json\_raw\_object method of String (which produces
25
27
  an object, that contains a byte array) and decode the result on the receiving
26
28
  endpoint.
27
29
 
28
- The JSON parsers can parse UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, and UTF-32LE
29
- JSON documents under Ruby 1.8. Under Ruby 1.9 they take advantage of Ruby's
30
- M17n features and can parse all documents which have the correct
31
- String#encoding set. If a document string has ASCII-8BIT as an encoding the
32
- parser attempts to figure out which of the UTF encodings from above it is and
33
- trys to parse it.
34
-
35
30
  ## Installation
36
31
 
37
32
  It's recommended to use the extension variant of JSON, because it's faster than
@@ -40,151 +35,211 @@ for the latter.
40
35
 
41
36
  Just type into the command line as root:
42
37
 
43
- # rake install
38
+ ```
39
+ # rake install
40
+ ```
44
41
 
45
42
  The above command will build the extensions and install them on your system.
46
43
 
47
- # rake install_pure
44
+ ```
45
+ # rake install_pure
46
+ ```
48
47
 
49
48
  or
50
49
 
51
- # ruby install.rb
50
+ ```
51
+ # ruby install.rb
52
+ ```
52
53
 
53
54
  will just install the pure ruby implementation of JSON.
54
55
 
55
56
  If you use Rubygems you can type
56
57
 
57
- # gem install json
58
+ ```
59
+ # gem install json
60
+ ```
58
61
 
59
62
  instead, to install the newest JSON version.
60
63
 
61
64
  There is also a pure ruby json only variant of the gem, that can be installed
62
65
  with:
63
66
 
64
- # gem install json_pure
67
+ ```
68
+ # gem install json_pure
69
+ ```
65
70
 
66
71
  ## Compiling the extensions yourself
67
72
 
68
- If you want to create the parser.c file from its parser.rl file or draw nice
73
+ If you want to create the `parser.c` file from its `parser.rl` file or draw nice
69
74
  graphviz images of the state machines, you need ragel from:
70
75
  http://www.complang.org/ragel/
71
76
 
72
77
  ## Usage
73
78
 
74
79
  To use JSON you can
75
- require 'json'
76
- to load the installed variant (either the extension 'json' or the pure
77
- variant 'json\_pure'). If you have installed the extension variant, you can
80
+
81
+ ```ruby
82
+ require 'json'
83
+ ```
84
+
85
+ to load the installed variant (either the extension `'json'` or the pure
86
+ variant `'json_pure'`). If you have installed the extension variant, you can
78
87
  pick either the extension variant or the pure variant by typing
79
- require 'json/ext'
88
+
89
+ ```ruby
90
+ require 'json/ext'
91
+ ```
92
+
80
93
  or
81
- require 'json/pure'
94
+
95
+ ```ruby
96
+ require 'json/pure'
97
+ ```
82
98
 
83
99
  Now you can parse a JSON document into a ruby data structure by calling
84
100
 
85
- JSON.parse(document)
101
+ ```ruby
102
+ JSON.parse(document)
103
+ ```
86
104
 
87
105
  If you want to generate a JSON document from a ruby data structure call
88
- JSON.generate(data)
106
+ ```ruby
107
+ JSON.generate(data)
108
+ ```
89
109
 
90
- You can also use the pretty\_generate method (which formats the output more
91
- verbosely and nicely) or fast\_generate (which doesn't do any of the security
110
+ You can also use the `pretty_generate` method (which formats the output more
111
+ verbosely and nicely) or `fast_generate` (which doesn't do any of the security
92
112
  checks generate performs, e. g. nesting deepness checks).
93
113
 
94
- To create a valid JSON document you have to make sure, that the output is
95
- embedded in either a JSON array [] or a JSON object {}. The easiest way to do
96
- this, is by putting your values in a Ruby Array or Hash instance.
97
-
98
114
  There are also the JSON and JSON[] methods which use parse on a String or
99
115
  generate a JSON document from an array or hash:
100
116
 
101
- document = JSON 'test' => 23 # => "{\"test\":23}"
102
- document = JSON['test'] => 23 # => "{\"test\":23}"
117
+ ```ruby
118
+ document = JSON 'test' => 23 # => "{\"test\":23}"
119
+ document = JSON['test' => 23] # => "{\"test\":23}"
120
+ ```
103
121
 
104
122
  and
105
123
 
106
- data = JSON '{"test":23}' # => {"test"=>23}
107
- data = JSON['{"test":23}'] # => {"test"=>23}
124
+ ```ruby
125
+ data = JSON '{"test":23}' # => {"test"=>23}
126
+ data = JSON['{"test":23}'] # => {"test"=>23}
127
+ ```
108
128
 
109
129
  You can choose to load a set of common additions to ruby core's objects if
110
130
  you
111
- require 'json/add/core'
131
+
132
+ ```ruby
133
+ require 'json/add/core'
134
+ ```
112
135
 
113
136
  After requiring this you can, e. g., serialise/deserialise Ruby ranges:
114
137
 
115
- JSON JSON(1..10) # => 1..10
138
+ ```ruby
139
+ JSON JSON(1..10) # => 1..10
140
+ ```
116
141
 
117
142
  To find out how to add JSON support to other or your own classes, read the
118
143
  section "More Examples" below.
119
144
 
120
145
  To get the best compatibility to rails' JSON implementation, you can
121
- require 'json/add/rails'
122
146
 
123
- Both of the additions attempt to require 'json' (like above) first, if it has
147
+ ```ruby
148
+ require 'json/add/rails'
149
+ ```
150
+
151
+ Both of the additions attempt to require `'json'` (like above) first, if it has
124
152
  not been required yet.
125
153
 
154
+ ## Serializing exceptions
155
+
156
+ The JSON module doesn't extend `Exception` by default. If you convert an `Exception`
157
+ object to JSON, it will by default only include the exception message.
158
+
159
+ To include the full details, you must either load the `json/add/core` mentioned
160
+ above, or specifically load the exception addition:
161
+
162
+ ```ruby
163
+ require 'json/add/exception'
164
+ ```
165
+
126
166
  ## More Examples
127
167
 
128
168
  To create a JSON document from a ruby data structure, you can call
129
- JSON.generate like that:
169
+ `JSON.generate` like that:
130
170
 
131
- json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
132
- # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
171
+ ```ruby
172
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
173
+ # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
174
+ ```
133
175
 
134
176
  To get back a ruby data structure from a JSON document, you have to call
135
177
  JSON.parse on it:
136
178
 
137
- JSON.parse json
138
- # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
179
+ ```ruby
180
+ JSON.parse json
181
+ # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
182
+ ```
139
183
 
140
184
  Note, that the range from the original data structure is a simple
141
185
  string now. The reason for this is, that JSON doesn't support ranges
142
186
  or arbitrary classes. In this case the json library falls back to call
143
- Object#to\_json, which is the same as #to\_s.to\_json.
187
+ `Object#to_json`, which is the same as `#to_s.to_json`.
144
188
 
145
189
  It's possible to add JSON support serialization to arbitrary classes by
146
- simply implementing a more specialized version of the #to\_json method, that
147
- should return a JSON object (a hash converted to JSON with #to\_json) like
148
- this (don't forget the *a for all the arguments):
149
-
150
- class Range
151
- def to_json(*a)
152
- {
153
- 'json_class' => self.class.name, # = 'Range'
154
- 'data' => [ first, last, exclude_end? ]
155
- }.to_json(*a)
156
- end
157
- end
158
-
159
- The hash key 'json\_class' is the class, that will be asked to deserialise the
160
- JSON representation later. In this case it's 'Range', but any namespace of
161
- the form 'A::B' or '::A::B' will do. All other keys are arbitrary and can be
190
+ simply implementing a more specialized version of the `#to_json method`, that
191
+ should return a JSON object (a hash converted to JSON with `#to_json`) like
192
+ this (don't forget the `*a` for all the arguments):
193
+
194
+ ```ruby
195
+ class Range
196
+ def to_json(*a)
197
+ {
198
+ 'json_class' => self.class.name, # = 'Range'
199
+ 'data' => [ first, last, exclude_end? ]
200
+ }.to_json(*a)
201
+ end
202
+ end
203
+ ```
204
+
205
+ The hash key `json_class` is the class, that will be asked to deserialise the
206
+ JSON representation later. In this case it's `Range`, but any namespace of
207
+ the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be
162
208
  used to store the necessary data to configure the object to be deserialised.
163
209
 
164
- If a the key 'json\_class' is found in a JSON object, the JSON parser checks
165
- if the given class responds to the json\_create class method. If so, it is
210
+ If the key `json_class` is found in a JSON object, the JSON parser checks
211
+ if the given class responds to the `json_create` class method. If so, it is
166
212
  called with the JSON object converted to a Ruby hash. So a range can
167
- be deserialised by implementing Range.json\_create like this:
213
+ be deserialised by implementing `Range.json_create` like this:
168
214
 
169
- class Range
170
- def self.json_create(o)
171
- new(*o['data'])
172
- end
173
- end
215
+ ```ruby
216
+ class Range
217
+ def self.json_create(o)
218
+ new(*o['data'])
219
+ end
220
+ end
221
+ ```
174
222
 
175
223
  Now it possible to serialise/deserialise ranges as well:
176
224
 
177
- json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
178
- # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
179
- JSON.parse json
180
- # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
181
-
182
- JSON.generate always creates the shortest possible string representation of a
225
+ ```ruby
226
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
227
+ # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
228
+ JSON.parse json
229
+ # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
230
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
231
+ # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
232
+ JSON.parse json, :create_additions => true
233
+ # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
234
+ ```
235
+
236
+ `JSON.generate` always creates the shortest possible string representation of a
183
237
  ruby data structure in one line. This is good for data storage or network
184
238
  protocols, but not so good for humans to read. Fortunately there's also
185
- JSON.pretty\_generate (or JSON.pretty\_generate) that creates a more readable
239
+ `JSON.pretty_generate` (or `JSON.pretty_generate`) that creates a more readable
186
240
  output:
187
241
 
242
+ ```ruby
188
243
  puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10])
189
244
  [
190
245
  1,
@@ -204,12 +259,13 @@ output:
204
259
  ]
205
260
  }
206
261
  ]
262
+ ```
207
263
 
208
- There are also the methods Kernel#j for generate, and Kernel#jj for
209
- pretty\_generate output to the console, that work analogous to Core Ruby's p and
210
- the pp library's pp methods.
264
+ There are also the methods `Kernel#j` for generate, and `Kernel#jj` for
265
+ `pretty_generate` output to the console, that work analogous to Core Ruby's `p` and
266
+ the `pp` library's `pp` methods.
211
267
 
212
- The script tools/server.rb contains a small example if you want to test, how
268
+ The script `tools/server.rb` contains a small example if you want to test, how
213
269
  receiving a JSON object from a webrick server in your browser with the
214
270
  javasript prototype library http://www.prototypejs.org works.
215
271
 
@@ -219,67 +275,72 @@ I have created some benchmark results (see the benchmarks/data-p4-3Ghz
219
275
  subdir of the package) for the JSON-parser to estimate the speed up in the C
220
276
  extension:
221
277
 
278
+ ```
222
279
  Comparing times (call_time_mean):
223
280
  1 ParserBenchmarkExt#parser 900 repeats:
224
- 553.922304770 ( real) -> 21.500x
281
+ 553.922304770 ( real) -> 21.500x
225
282
  0.001805307
226
283
  2 ParserBenchmarkYAML#parser 1000 repeats:
227
- 224.513358139 ( real) -> 8.714x
284
+ 224.513358139 ( real) -> 8.714x
228
285
  0.004454078
229
286
  3 ParserBenchmarkPure#parser 1000 repeats:
230
- 26.755020642 ( real) -> 1.038x
287
+ 26.755020642 ( real) -> 1.038x
231
288
  0.037376163
232
289
  4 ParserBenchmarkRails#parser 1000 repeats:
233
- 25.763381731 ( real) -> 1.000x
290
+ 25.763381731 ( real) -> 1.000x
234
291
  0.038814780
235
292
  calls/sec ( time) -> speed covers
236
293
  secs/call
294
+ ```
237
295
 
238
- In the table above 1 is JSON::Ext::Parser, 2 is YAML.load with YAML
239
- compatbile JSON document, 3 is is JSON::Pure::Parser, and 4 is
240
- ActiveSupport::JSON.decode. The ActiveSupport JSON-decoder converts the
296
+ In the table above 1 is `JSON::Ext::Parser`, 2 is `YAML.load` with YAML
297
+ compatbile JSON document, 3 is is `JSON::Pure::Parser`, and 4 is
298
+ `ActiveSupport::JSON.decode`. The ActiveSupport JSON-decoder converts the
241
299
  input first to YAML and then uses the YAML-parser, the conversion seems to
242
- slow it down so much that it is only as fast as the JSON::Pure::Parser!
300
+ slow it down so much that it is only as fast as the `JSON::Pure::Parser`!
243
301
 
244
302
  If you look at the benchmark data you can see that this is mostly caused by
245
303
  the frequent high outliers - the median of the Rails-parser runs is still
246
- overall smaller than the median of the JSON::Pure::Parser runs:
304
+ overall smaller than the median of the `JSON::Pure::Parser` runs:
247
305
 
306
+ ```
248
307
  Comparing times (call_time_median):
249
308
  1 ParserBenchmarkExt#parser 900 repeats:
250
- 800.592479481 ( real) -> 26.936x
309
+ 800.592479481 ( real) -> 26.936x
251
310
  0.001249075
252
311
  2 ParserBenchmarkYAML#parser 1000 repeats:
253
- 271.002390644 ( real) -> 9.118x
312
+ 271.002390644 ( real) -> 9.118x
254
313
  0.003690004
255
314
  3 ParserBenchmarkRails#parser 1000 repeats:
256
- 30.227910865 ( real) -> 1.017x
315
+ 30.227910865 ( real) -> 1.017x
257
316
  0.033082008
258
317
  4 ParserBenchmarkPure#parser 1000 repeats:
259
- 29.722384421 ( real) -> 1.000x
318
+ 29.722384421 ( real) -> 1.000x
260
319
  0.033644676
261
320
  calls/sec ( time) -> speed covers
262
321
  secs/call
322
+ ```
263
323
 
264
- I have benchmarked the JSON-Generator as well. This generated a few more
324
+ I have benchmarked the `JSON-Generator` as well. This generated a few more
265
325
  values, because there are different modes that also influence the achieved
266
326
  speed:
267
327
 
328
+ ```
268
329
  Comparing times (call_time_mean):
269
330
  1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
270
- 547.354332608 ( real) -> 15.090x
331
+ 547.354332608 ( real) -> 15.090x
271
332
  0.001826970
272
333
  2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
273
- 443.968212317 ( real) -> 12.240x
334
+ 443.968212317 ( real) -> 12.240x
274
335
  0.002252414
275
336
  3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
276
- 375.104545883 ( real) -> 10.341x
337
+ 375.104545883 ( real) -> 10.341x
277
338
  0.002665923
278
339
  4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
279
- 49.978706968 ( real) -> 1.378x
340
+ 49.978706968 ( real) -> 1.378x
280
341
  0.020008521
281
342
  5 GeneratorBenchmarkRails#generator 1000 repeats:
282
- 38.531868759 ( real) -> 1.062x
343
+ 38.531868759 ( real) -> 1.062x
283
344
  0.025952543
284
345
  6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
285
346
  36.927649925 ( real) -> 1.018x 7 (>=3859)
@@ -289,33 +350,35 @@ speed:
289
350
  0.027569373
290
351
  calls/sec ( time) -> speed covers
291
352
  secs/call
353
+ ```
292
354
 
293
- In the table above 1-3 are JSON::Ext::Generator methods. 4, 6, and 7 are
294
- JSON::Pure::Generator methods and 5 is the Rails JSON generator. It is now a
295
- bit faster than the generator\_safe and generator\_pretty methods of the pure
355
+ In the table above 1-3 are `JSON::Ext::Generator` methods. 4, 6, and 7 are
356
+ `JSON::Pure::Generator` methods and 5 is the Rails JSON generator. It is now a
357
+ bit faster than the `generator_safe` and `generator_pretty` methods of the pure
296
358
  variant but slower than the others.
297
359
 
298
- To achieve the fastest JSON document output, you can use the fast\_generate
360
+ To achieve the fastest JSON document output, you can use the `fast_generate`
299
361
  method. Beware, that this will disable the checking for circular Ruby data
300
362
  structures, which may cause JSON to go into an infinite loop.
301
363
 
302
364
  Here are the median comparisons for completeness' sake:
303
365
 
366
+ ```
304
367
  Comparing times (call_time_median):
305
368
  1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
306
- 708.258020939 ( real) -> 16.547x
369
+ 708.258020939 ( real) -> 16.547x
307
370
  0.001411915
308
371
  2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
309
- 569.105020353 ( real) -> 13.296x
372
+ 569.105020353 ( real) -> 13.296x
310
373
  0.001757145
311
374
  3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
312
- 482.825371244 ( real) -> 11.280x
375
+ 482.825371244 ( real) -> 11.280x
313
376
  0.002071142
314
377
  4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
315
- 62.717626652 ( real) -> 1.465x
378
+ 62.717626652 ( real) -> 1.465x
316
379
  0.015944481
317
380
  5 GeneratorBenchmarkRails#generator 1000 repeats:
318
- 43.965681162 ( real) -> 1.027x
381
+ 43.965681162 ( real) -> 1.027x
319
382
  0.022745013
320
383
  6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
321
384
  43.929073409 ( real) -> 1.026x 7 (>=3859)
@@ -325,6 +388,23 @@ Here are the median comparisons for completeness' sake:
325
388
  0.023363113
326
389
  calls/sec ( time) -> speed covers
327
390
  secs/call
391
+ ```
392
+
393
+ ## Development
394
+
395
+ ### Release
396
+
397
+ Update the json.gemspec and json-java.gemspec.
398
+
399
+ ```
400
+ rbenv shell 2.6.5
401
+ rake build
402
+ gem push pkg/json-2.3.0.gem
403
+
404
+ rbenv shell jruby-9.2.9.0
405
+ rake build
406
+ gem push pkg/json-2.3.0-java.gem
407
+ ```
328
408
 
329
409
  ## Author
330
410
 
@@ -342,4 +422,4 @@ The latest version of this library can be downloaded at
342
422
 
343
423
  Online Documentation should be located at
344
424
 
345
- * http://json.rubyforge.org
425
+ * https://www.rubydoc.info/gems/json