json 1.8.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of json might be problematic. Click here for more details.

Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -10
  3. data/CHANGES +12 -0
  4. data/Gemfile +1 -2
  5. data/{README.rdoc → README.md} +145 -111
  6. data/Rakefile +26 -29
  7. data/VERSION +1 -1
  8. data/ext/json/ext/generator/generator.c +38 -55
  9. data/ext/json/ext/generator/generator.h +7 -1
  10. data/ext/json/ext/parser/extconf.rb +3 -0
  11. data/ext/json/ext/parser/parser.c +309 -439
  12. data/ext/json/ext/parser/parser.h +0 -1
  13. data/ext/json/ext/parser/parser.rl +67 -160
  14. data/ext/json/extconf.rb +0 -1
  15. data/java/src/json/ext/ByteListTranscoder.java +1 -2
  16. data/java/src/json/ext/Generator.java +11 -12
  17. data/java/src/json/ext/GeneratorMethods.java +1 -2
  18. data/java/src/json/ext/GeneratorService.java +1 -2
  19. data/java/src/json/ext/GeneratorState.java +3 -56
  20. data/java/src/json/ext/OptionsReader.java +2 -3
  21. data/java/src/json/ext/Parser.java +110 -411
  22. data/java/src/json/ext/Parser.rl +25 -119
  23. data/java/src/json/ext/ParserService.java +1 -2
  24. data/java/src/json/ext/RuntimeInfo.java +1 -6
  25. data/java/src/json/ext/StringDecoder.java +1 -2
  26. data/java/src/json/ext/StringEncoder.java +5 -0
  27. data/java/src/json/ext/Utils.java +1 -2
  28. data/json-java.gemspec +15 -0
  29. data/json.gemspec +0 -0
  30. data/json_pure.gemspec +23 -26
  31. data/lib/json/add/bigdecimal.rb +1 -0
  32. data/lib/json/add/complex.rb +2 -1
  33. data/lib/json/add/core.rb +1 -0
  34. data/lib/json/add/date.rb +1 -1
  35. data/lib/json/add/date_time.rb +1 -1
  36. data/lib/json/add/exception.rb +1 -1
  37. data/lib/json/add/ostruct.rb +1 -1
  38. data/lib/json/add/range.rb +1 -1
  39. data/lib/json/add/rational.rb +1 -0
  40. data/lib/json/add/regexp.rb +1 -1
  41. data/lib/json/add/struct.rb +1 -1
  42. data/lib/json/add/symbol.rb +1 -1
  43. data/lib/json/add/time.rb +1 -1
  44. data/lib/json/common.rb +24 -52
  45. data/lib/json/ext.rb +0 -6
  46. data/lib/json/generic_object.rb +5 -4
  47. data/lib/json/pure/generator.rb +61 -125
  48. data/lib/json/pure/parser.rb +28 -80
  49. data/lib/json/pure.rb +2 -8
  50. data/lib/json/version.rb +2 -1
  51. data/lib/json.rb +1 -0
  52. data/references/rfc7159.txt +899 -0
  53. data/tests/fixtures/obsolete_fail1.json +1 -0
  54. data/tests/{test_json_addition.rb → json_addition_test.rb} +22 -25
  55. data/tests/json_common_interface_test.rb +126 -0
  56. data/tests/json_encoding_test.rb +105 -0
  57. data/tests/json_ext_parser_test.rb +15 -0
  58. data/tests/{test_json_fixtures.rb → json_fixtures_test.rb} +5 -8
  59. data/tests/{test_json_generate.rb → json_generator_test.rb} +76 -37
  60. data/tests/{test_json_generic_object.rb → json_generic_object_test.rb} +15 -8
  61. data/tests/json_parser_test.rb +448 -0
  62. data/tests/json_string_matching_test.rb +38 -0
  63. data/tests/test_helper.rb +23 -0
  64. data/tools/diff.sh +18 -0
  65. data/tools/fuzz.rb +1 -9
  66. metadata +27 -42
  67. data/COPYING +0 -58
  68. data/COPYING-json-jruby +0 -57
  69. data/GPL +0 -340
  70. data/TODO +0 -1
  71. data/tests/fixtures/fail1.json +0 -1
  72. data/tests/setup_variant.rb +0 -11
  73. data/tests/test_json.rb +0 -553
  74. data/tests/test_json_encoding.rb +0 -65
  75. data/tests/test_json_string_matching.rb +0 -39
  76. data/tests/test_json_unicode.rb +0 -72
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80c313748cbdd4d21299d85d68b5fad41fc042ed
4
- data.tar.gz: 6ec0ef5f281c89d45401a266d75023e0e6e1414f
3
+ metadata.gz: 8ea58c6d7f4166c9c44e7c5c09b9dddcc5e7e4fa
4
+ data.tar.gz: 7bb5f27daeedbd962911bedcc4a599cc11ee7c87
5
5
  SHA512:
6
- metadata.gz: 662fd98151f47aeaaa3e0c90be27331aed79a17ff5871e8751803f2e1398ffdfa46952b098099b3bdc0e10ed1fed0280a52d728f2570e33d8b37ad39f31b7c4a
7
- data.tar.gz: c5908b10b4a178e0869b6fa26f48d65ccd78e6e0df971db9abb4eace9c33486021098936421ad30939aa6dcb8600aac5ba3f37584841417518af35dd1bfea2fb
6
+ metadata.gz: 682e3deed31ab69160034d51060aa34cf494338db37ea1580523652fedf008196246d08b390fdf0975168e557e92c863077c7d991f6de0f413fb0873937892e6
7
+ data.tar.gz: c7f75172c95785474562701804306301e47943cdcc887ac066c5d28721f33fef3f1135dd3e6dbfd2237e2db6ab1f55bf5af20ad99b261d563f5994e9680e274a
data/.travis.yml CHANGED
@@ -4,23 +4,17 @@ language: ruby
4
4
 
5
5
  # Specify which ruby versions you wish to run your tests on, each version will be used
6
6
  rvm:
7
- - 1.8.7
8
- - 1.9.2
9
- - 1.9.3
10
7
  - 2.0.0
11
8
  - 2.1
12
- - 2.2.1
13
- - 2.2.2
14
9
  - 2.2
15
- - ree
16
- - rbx-2
17
- - jruby-18mode
18
- - jruby-19mode
10
+ - 2.3.1
19
11
  - ruby-head
20
12
  matrix:
13
+ include:
14
+ - rvm: jruby
15
+ env: JRUBY_OPTS="--2.0"
21
16
  allow_failures:
22
17
  - rvm: rbx-2
23
18
  - rvm: ruby-head
24
19
  script: "bundle exec rake"
25
-
26
20
  sudo: false
data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ 2015-09-11 (2.0.0)
2
+ * Now complies to newest JSON RFC 7159.
3
+ * Implements compatibiliy to ruby 2.4 integer unification.
4
+ * Drops support for old rubies whose life has ended, that is rubies < 2.0.
5
+ Also see https://www.ruby-lang.org/en/news/2014/07/01/eol-for-1-8-7-and-1-9-2/
6
+ * There were still some mentions of dual GPL licensing in the source, but JSON
7
+ has just the Ruby license that itself includes an explicit dual-licensing
8
+ clause that allows covered software to be distributed under the terms of
9
+ the Simplified BSD License instead for all ruby versions >= 1.9.3. This is
10
+ however a GPL compatible license according to the Free Software Foundation.
11
+ I changed these mentions to be consistent with the Ruby license setting in
12
+ the gemspec files which were already correct now.
1
13
  2015-06-01 (1.8.3)
2
14
  * Fix potential memory leak, thx to nobu.
3
15
  2015-01-08 (1.8.2)
data/Gemfile CHANGED
@@ -6,5 +6,4 @@ gemspec :name => 'json'
6
6
  gemspec :name => 'json_pure'
7
7
  gemspec :name => 'json-java'
8
8
 
9
- gem 'utils'
10
- gem 'test-unit'
9
+ gem 'simplecov'
@@ -1,6 +1,7 @@
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 ![Travis Widget]
2
+ [Travis Widget]: http://travis-ci.org/flori/json.svg?branch=master
2
3
 
3
- == Description
4
+ ## Description
4
5
 
5
6
  This is a implementation of the JSON specification according to RFC 4627
6
7
  http://www.ietf.org/rfc/rfc4627.txt . Starting from version 1.0.0 on there
@@ -11,28 +12,21 @@ will be two variants available:
11
12
  * The quite a bit faster native extension variant, which is in parts
12
13
  implemented in C or Java and comes with its own unicode conversion
13
14
  functions and a parser generated by the ragel state machine compiler
14
- http://www.cs.queensu.ca/~thurston/ragel .
15
+ http://www.complang.org/ragel/ .
15
16
 
16
17
  Both variants of the JSON generator generate UTF-8 character sequences by
17
- default. If an :ascii_only option with a true value is given, they escape all
18
+ default. If an :ascii\_only option with a true value is given, they escape all
18
19
  non-ASCII and control characters with \uXXXX escape sequences, and support
19
20
  UTF-16 surrogate pairs in order to be able to generate the whole range of
20
21
  unicode code points.
21
22
 
22
23
  All strings, that are to be encoded as JSON strings, should be UTF-8 byte
23
24
  sequences on the Ruby side. To encode raw binary strings, that aren't UTF-8
24
- encoded, please use the to_json_raw_object method of String (which produces
25
+ encoded, please use the to\_json\_raw\_object method of String (which produces
25
26
  an object, that contains a byte array) and decode the result on the receiving
26
27
  endpoint.
27
28
 
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
- == Installation
29
+ ## Installation
36
30
 
37
31
  It's recommended to use the extension variant of JSON, because it's faster than
38
32
  the pure ruby variant. If you cannot build it on your system, you can settle
@@ -40,124 +34,151 @@ for the latter.
40
34
 
41
35
  Just type into the command line as root:
42
36
 
43
- # rake install
37
+ ```
38
+ # rake install
39
+ ```
44
40
 
45
41
  The above command will build the extensions and install them on your system.
46
42
 
47
- # rake install_pure
43
+ ```
44
+ # rake install_pure
45
+ ```
48
46
 
49
47
  or
50
48
 
51
- # ruby install.rb
49
+ ```
50
+ # ruby install.rb
51
+ ```
52
52
 
53
53
  will just install the pure ruby implementation of JSON.
54
54
 
55
55
  If you use Rubygems you can type
56
56
 
57
- # gem install json
57
+ ```
58
+ # gem install json
59
+ ```
58
60
 
59
61
  instead, to install the newest JSON version.
60
62
 
61
63
  There is also a pure ruby json only variant of the gem, that can be installed
62
64
  with:
63
65
 
64
- # gem install json_pure
65
-
66
- == Compiling the extensions yourself
66
+ ```
67
+ # gem install json_pure
68
+ ```
67
69
 
68
- If you want to build the extensions yourself you need rake:
70
+ ## Compiling the extensions yourself
69
71
 
70
- You can get it from rubyforge:
71
- http://rubyforge.org/projects/rake
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 from:
74
+ http://www.complang.org/ragel/
72
75
 
73
- or just type
76
+ ## Usage
74
77
 
75
- # gem install rake
76
-
77
- for the installation via rubygems.
78
+ To use JSON you can
78
79
 
79
- If you want to create the parser.c file from its parser.rl file or draw nice
80
- graphviz images of the state machines, you need ragel from: http://www.cs.queensu.ca/~thurston/ragel
80
+ ```ruby
81
+ require 'json'
82
+ ```
81
83
 
84
+ to load the installed variant (either the extension `'json'` or the pure
85
+ variant `'json_pure'`). If you have installed the extension variant, you can
86
+ pick either the extension variant or the pure variant by typing
82
87
 
83
- == Usage
88
+ ```ruby
89
+ require 'json/ext'
90
+ ```
84
91
 
85
- To use JSON you can
86
- require 'json'
87
- to load the installed variant (either the extension 'json' or the pure
88
- variant 'json_pure'). If you have installed the extension variant, you can
89
- pick either the extension variant or the pure variant by typing
90
- require 'json/ext'
91
92
  or
92
- require 'json/pure'
93
+
94
+ ```ruby
95
+ require 'json/pure'
96
+ ```
93
97
 
94
98
  Now you can parse a JSON document into a ruby data structure by calling
95
99
 
96
- JSON.parse(document)
100
+ ```ruby
101
+ JSON.parse(document)
102
+ ```
97
103
 
98
104
  If you want to generate a JSON document from a ruby data structure call
99
- JSON.generate(data)
105
+ ```ruby
106
+ JSON.generate(data)
107
+ ```
100
108
 
101
- You can also use the pretty_generate method (which formats the output more
102
- verbosely and nicely) or fast_generate (which doesn't do any of the security
109
+ You can also use the `pretty_generate` method (which formats the output more
110
+ verbosely and nicely) or `fast_generate` (which doesn't do any of the security
103
111
  checks generate performs, e. g. nesting deepness checks).
104
112
 
105
- To create a valid JSON document you have to make sure, that the output is
106
- embedded in either a JSON array [] or a JSON object {}. The easiest way to do
107
- this, is by putting your values in a Ruby Array or Hash instance.
108
-
109
113
  There are also the JSON and JSON[] methods which use parse on a String or
110
114
  generate a JSON document from an array or hash:
111
115
 
112
- document = JSON 'test' => 23 # => "{\"test\":23}"
113
- document = JSON['test'] => 23 # => "{\"test\":23}"
116
+ ```ruby
117
+ document = JSON 'test' => 23 # => "{\"test\":23}"
118
+ document = JSON['test'] => 23 # => "{\"test\":23}"
119
+ ```
114
120
 
115
121
  and
116
122
 
117
- data = JSON '{"test":23}' # => {"test"=>23}
118
- data = JSON['{"test":23}'] # => {"test"=>23}
123
+ ```ruby
124
+ data = JSON '{"test":23}' # => {"test"=>23}
125
+ data = JSON['{"test":23}'] # => {"test"=>23}
126
+ ```
119
127
 
120
128
  You can choose to load a set of common additions to ruby core's objects if
121
129
  you
122
- require 'json/add/core'
130
+
131
+ ```ruby
132
+ require 'json/add/core'
133
+ ```
123
134
 
124
135
  After requiring this you can, e. g., serialise/deserialise Ruby ranges:
125
136
 
126
- JSON JSON(1..10) # => 1..10
137
+ ```ruby
138
+ JSON JSON(1..10) # => 1..10
139
+ ```
127
140
 
128
141
  To find out how to add JSON support to other or your own classes, read the
129
142
  section "More Examples" below.
130
143
 
131
144
  To get the best compatibility to rails' JSON implementation, you can
132
- require 'json/add/rails'
133
145
 
134
- Both of the additions attempt to require 'json' (like above) first, if it has
146
+ ```ruby
147
+ require 'json/add/rails'
148
+ ```
149
+
150
+ Both of the additions attempt to require `'json'` (like above) first, if it has
135
151
  not been required yet.
136
152
 
137
- == More Examples
153
+ ## More Examples
138
154
 
139
155
  To create a JSON document from a ruby data structure, you can call
140
- JSON.generate like that:
156
+ `JSON.generate` like that:
141
157
 
142
- json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
143
- # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
158
+ ```ruby
159
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
160
+ # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
161
+ ```
144
162
 
145
163
  To get back a ruby data structure from a JSON document, you have to call
146
164
  JSON.parse on it:
147
165
 
148
- JSON.parse json
149
- # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
166
+ ```ruby
167
+ JSON.parse json
168
+ # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
169
+ ```
150
170
 
151
171
  Note, that the range from the original data structure is a simple
152
172
  string now. The reason for this is, that JSON doesn't support ranges
153
173
  or arbitrary classes. In this case the json library falls back to call
154
- Object#to_json, which is the same as #to_s.to_json.
174
+ `Object#to_json`, which is the same as `#to_s.to_json`.
155
175
 
156
176
  It's possible to add JSON support serialization to arbitrary classes by
157
- simply implementing a more specialized version of the #to_json method, that
158
- should return a JSON object (a hash converted to JSON with #to_json) like
159
- this (don't forget the *a for all the arguments):
177
+ simply implementing a more specialized version of the `#to_json method`, that
178
+ should return a JSON object (a hash converted to JSON with `#to_json`) like
179
+ this (don't forget the `*a` for all the arguments):
160
180
 
181
+ ```ruby
161
182
  class Range
162
183
  def to_json(*a)
163
184
  {
@@ -166,36 +187,42 @@ this (don't forget the *a for all the arguments):
166
187
  }.to_json(*a)
167
188
  end
168
189
  end
190
+ ```
169
191
 
170
- The hash key 'json_class' is the class, that will be asked to deserialise the
171
- JSON representation later. In this case it's 'Range', but any namespace of
172
- the form 'A::B' or '::A::B' will do. All other keys are arbitrary and can be
192
+ The hash key `json_class` is the class, that will be asked to deserialise the
193
+ JSON representation later. In this case it's `Range`, but any namespace of
194
+ the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be
173
195
  used to store the necessary data to configure the object to be deserialised.
174
196
 
175
- If a the key 'json_class' is found in a JSON object, the JSON parser checks
176
- if the given class responds to the json_create class method. If so, it is
197
+ If a the key `json_class` is found in a JSON object, the JSON parser checks
198
+ if the given class responds to the `json_create` class method. If so, it is
177
199
  called with the JSON object converted to a Ruby hash. So a range can
178
- be deserialised by implementing Range.json_create like this:
200
+ be deserialised by implementing `Range.json_create` like this:
179
201
 
202
+ ```ruby
180
203
  class Range
181
204
  def self.json_create(o)
182
205
  new(*o['data'])
183
206
  end
184
207
  end
208
+ ```
185
209
 
186
210
  Now it possible to serialise/deserialise ranges as well:
187
211
 
212
+ ```ruby
188
213
  json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
189
214
  # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
190
215
  JSON.parse json
191
216
  # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
217
+ ```
192
218
 
193
- JSON.generate always creates the shortest possible string representation of a
219
+ `JSON.generate` always creates the shortest possible string representation of a
194
220
  ruby data structure in one line. This is good for data storage or network
195
221
  protocols, but not so good for humans to read. Fortunately there's also
196
- JSON.pretty_generate (or JSON.pretty_generate) that creates a more readable
222
+ `JSON.pretty_generate` (or `JSON.pretty_generate`) that creates a more readable
197
223
  output:
198
224
 
225
+ ```ruby
199
226
  puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10])
200
227
  [
201
228
  1,
@@ -215,82 +242,88 @@ output:
215
242
  ]
216
243
  }
217
244
  ]
245
+ ```
218
246
 
219
- There are also the methods Kernel#j for generate, and Kernel#jj for
220
- pretty_generate output to the console, that work analogous to Core Ruby's p and
221
- the pp library's pp methods.
247
+ There are also the methods `Kernel#j` for generate, and `Kernel#jj` for
248
+ `pretty_generate` output to the console, that work analogous to Core Ruby's `p` and
249
+ the `pp` library's `pp` methods.
222
250
 
223
- The script tools/server.rb contains a small example if you want to test, how
251
+ The script `tools/server.rb` contains a small example if you want to test, how
224
252
  receiving a JSON object from a webrick server in your browser with the
225
253
  javasript prototype library http://www.prototypejs.org works.
226
254
 
227
- == Speed Comparisons
255
+ ## Speed Comparisons
228
256
 
229
257
  I have created some benchmark results (see the benchmarks/data-p4-3Ghz
230
258
  subdir of the package) for the JSON-parser to estimate the speed up in the C
231
259
  extension:
232
260
 
261
+ ```
233
262
  Comparing times (call_time_mean):
234
263
  1 ParserBenchmarkExt#parser 900 repeats:
235
- 553.922304770 ( real) -> 21.500x
264
+ 553.922304770 ( real) -> 21.500x
236
265
  0.001805307
237
266
  2 ParserBenchmarkYAML#parser 1000 repeats:
238
- 224.513358139 ( real) -> 8.714x
267
+ 224.513358139 ( real) -> 8.714x
239
268
  0.004454078
240
269
  3 ParserBenchmarkPure#parser 1000 repeats:
241
- 26.755020642 ( real) -> 1.038x
270
+ 26.755020642 ( real) -> 1.038x
242
271
  0.037376163
243
272
  4 ParserBenchmarkRails#parser 1000 repeats:
244
- 25.763381731 ( real) -> 1.000x
273
+ 25.763381731 ( real) -> 1.000x
245
274
  0.038814780
246
275
  calls/sec ( time) -> speed covers
247
276
  secs/call
277
+ ```
248
278
 
249
- In the table above 1 is JSON::Ext::Parser, 2 is YAML.load with YAML
250
- compatbile JSON document, 3 is is JSON::Pure::Parser, and 4 is
251
- ActiveSupport::JSON.decode. The ActiveSupport JSON-decoder converts the
279
+ In the table above 1 is `JSON::Ext::Parser`, 2 is `YAML.load` with YAML
280
+ compatbile JSON document, 3 is is `JSON::Pure::Parser`, and 4 is
281
+ `ActiveSupport::JSON.decode`. The ActiveSupport JSON-decoder converts the
252
282
  input first to YAML and then uses the YAML-parser, the conversion seems to
253
- slow it down so much that it is only as fast as the JSON::Pure::Parser!
283
+ slow it down so much that it is only as fast as the `JSON::Pure::Parser`!
254
284
 
255
285
  If you look at the benchmark data you can see that this is mostly caused by
256
286
  the frequent high outliers - the median of the Rails-parser runs is still
257
- overall smaller than the median of the JSON::Pure::Parser runs:
287
+ overall smaller than the median of the `JSON::Pure::Parser` runs:
258
288
 
289
+ ```
259
290
  Comparing times (call_time_median):
260
291
  1 ParserBenchmarkExt#parser 900 repeats:
261
- 800.592479481 ( real) -> 26.936x
292
+ 800.592479481 ( real) -> 26.936x
262
293
  0.001249075
263
294
  2 ParserBenchmarkYAML#parser 1000 repeats:
264
- 271.002390644 ( real) -> 9.118x
295
+ 271.002390644 ( real) -> 9.118x
265
296
  0.003690004
266
297
  3 ParserBenchmarkRails#parser 1000 repeats:
267
- 30.227910865 ( real) -> 1.017x
298
+ 30.227910865 ( real) -> 1.017x
268
299
  0.033082008
269
300
  4 ParserBenchmarkPure#parser 1000 repeats:
270
- 29.722384421 ( real) -> 1.000x
301
+ 29.722384421 ( real) -> 1.000x
271
302
  0.033644676
272
303
  calls/sec ( time) -> speed covers
273
304
  secs/call
305
+ ```
274
306
 
275
- I have benchmarked the JSON-Generator as well. This generated a few more
307
+ I have benchmarked the `JSON-Generator` as well. This generated a few more
276
308
  values, because there are different modes that also influence the achieved
277
309
  speed:
278
310
 
311
+ ```
279
312
  Comparing times (call_time_mean):
280
313
  1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
281
- 547.354332608 ( real) -> 15.090x
314
+ 547.354332608 ( real) -> 15.090x
282
315
  0.001826970
283
316
  2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
284
- 443.968212317 ( real) -> 12.240x
317
+ 443.968212317 ( real) -> 12.240x
285
318
  0.002252414
286
319
  3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
287
- 375.104545883 ( real) -> 10.341x
320
+ 375.104545883 ( real) -> 10.341x
288
321
  0.002665923
289
322
  4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
290
- 49.978706968 ( real) -> 1.378x
323
+ 49.978706968 ( real) -> 1.378x
291
324
  0.020008521
292
325
  5 GeneratorBenchmarkRails#generator 1000 repeats:
293
- 38.531868759 ( real) -> 1.062x
326
+ 38.531868759 ( real) -> 1.062x
294
327
  0.025952543
295
328
  6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
296
329
  36.927649925 ( real) -> 1.018x 7 (>=3859)
@@ -300,33 +333,35 @@ speed:
300
333
  0.027569373
301
334
  calls/sec ( time) -> speed covers
302
335
  secs/call
336
+ ```
303
337
 
304
- In the table above 1-3 are JSON::Ext::Generator methods. 4, 6, and 7 are
305
- JSON::Pure::Generator methods and 5 is the Rails JSON generator. It is now a
306
- bit faster than the generator_safe and generator_pretty methods of the pure
338
+ In the table above 1-3 are `JSON::Ext::Generator` methods. 4, 6, and 7 are
339
+ `JSON::Pure::Generator` methods and 5 is the Rails JSON generator. It is now a
340
+ bit faster than the `generator_safe` and `generator_pretty` methods of the pure
307
341
  variant but slower than the others.
308
342
 
309
- To achieve the fastest JSON document output, you can use the fast_generate
343
+ To achieve the fastest JSON document output, you can use the `fast_generate`
310
344
  method. Beware, that this will disable the checking for circular Ruby data
311
345
  structures, which may cause JSON to go into an infinite loop.
312
346
 
313
347
  Here are the median comparisons for completeness' sake:
314
348
 
349
+ ```
315
350
  Comparing times (call_time_median):
316
351
  1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
317
- 708.258020939 ( real) -> 16.547x
352
+ 708.258020939 ( real) -> 16.547x
318
353
  0.001411915
319
354
  2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
320
- 569.105020353 ( real) -> 13.296x
355
+ 569.105020353 ( real) -> 13.296x
321
356
  0.001757145
322
357
  3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
323
- 482.825371244 ( real) -> 11.280x
358
+ 482.825371244 ( real) -> 11.280x
324
359
  0.002071142
325
360
  4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
326
- 62.717626652 ( real) -> 1.465x
361
+ 62.717626652 ( real) -> 1.465x
327
362
  0.015944481
328
363
  5 GeneratorBenchmarkRails#generator 1000 repeats:
329
- 43.965681162 ( real) -> 1.027x
364
+ 43.965681162 ( real) -> 1.027x
330
365
  0.022745013
331
366
  6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
332
367
  43.929073409 ( real) -> 1.026x 7 (>=3859)
@@ -336,22 +371,21 @@ Here are the median comparisons for completeness' sake:
336
371
  0.023363113
337
372
  calls/sec ( time) -> speed covers
338
373
  secs/call
374
+ ```
339
375
 
340
- == Author
376
+ ## Author
341
377
 
342
378
  Florian Frank <mailto:flori@ping.de>
343
379
 
344
- == License
380
+ ## License
345
381
 
346
- Ruby License, see the COPYING file included in the source distribution. The
347
- Ruby License includes the GNU General Public License (GPL), Version 2, so see
348
- the file GPL as well.
382
+ Ruby License, see https://www.ruby-lang.org/en/about/license.txt.
349
383
 
350
- == Download
384
+ ## Download
351
385
 
352
386
  The latest version of this library can be downloaded at
353
387
 
354
- * http://rubyforge.org/frs?group_id=953
388
+ * https://rubygems.org/gems/json
355
389
 
356
390
  Online Documentation should be located at
357
391