json 2.0.3 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES.md +66 -0
- data/Gemfile +1 -3
- data/LICENSE +56 -0
- data/README.md +54 -21
- data/VERSION +1 -1
- data/ext/json/ext/fbuffer/fbuffer.h +0 -3
- data/ext/json/ext/generator/generator.c +229 -54
- data/ext/json/ext/generator/generator.h +5 -3
- data/ext/json/ext/parser/extconf.rb +25 -0
- data/ext/json/ext/parser/parser.c +180 -85
- data/ext/json/ext/parser/parser.h +2 -0
- data/ext/json/ext/parser/parser.rl +104 -9
- data/ext/json/extconf.rb +1 -0
- data/json.gemspec +0 -0
- data/lib/json/add/bigdecimal.rb +2 -2
- data/lib/json/add/complex.rb +2 -3
- data/lib/json/add/ostruct.rb +1 -1
- data/lib/json/add/rational.rb +2 -3
- data/lib/json/add/regexp.rb +2 -2
- data/lib/json/add/set.rb +29 -0
- data/lib/json/common.rb +372 -125
- data/lib/json/pure/generator.rb +31 -10
- data/lib/json/pure/parser.rb +35 -5
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +549 -29
- data/tests/fixtures/fail29.json +1 -0
- data/tests/fixtures/fail30.json +1 -0
- data/tests/fixtures/fail31.json +1 -0
- data/tests/fixtures/fail32.json +1 -0
- data/tests/json_addition_test.rb +6 -0
- data/tests/json_common_interface_test.rb +47 -4
- data/tests/json_encoding_test.rb +2 -0
- data/tests/json_fixtures_test.rb +9 -1
- data/tests/json_generator_test.rb +30 -8
- data/tests/json_parser_test.rb +43 -12
- data/tests/lib/core_assertions.rb +763 -0
- data/tests/lib/envutil.rb +365 -0
- data/tests/lib/find_executable.rb +22 -0
- data/tests/lib/helper.rb +4 -0
- data/tests/ractor_test.rb +30 -0
- data/tests/test_helper.rb +3 -7
- metadata +31 -44
- data/.gitignore +0 -17
- data/.travis.yml +0 -19
- data/README-json-jruby.md +0 -33
- data/Rakefile +0 -408
- data/data/example.json +0 -1
- data/data/index.html +0 -38
- data/data/prototype.js +0 -4184
- data/diagrams/.keep +0 -0
- data/install.rb +0 -23
- data/java/src/json/ext/ByteListTranscoder.java +0 -166
- data/java/src/json/ext/Generator.java +0 -443
- data/java/src/json/ext/GeneratorMethods.java +0 -231
- data/java/src/json/ext/GeneratorService.java +0 -42
- data/java/src/json/ext/GeneratorState.java +0 -490
- data/java/src/json/ext/OptionsReader.java +0 -113
- data/java/src/json/ext/Parser.java +0 -2347
- data/java/src/json/ext/Parser.rl +0 -878
- data/java/src/json/ext/ParserService.java +0 -34
- data/java/src/json/ext/RuntimeInfo.java +0 -116
- data/java/src/json/ext/StringDecoder.java +0 -166
- data/java/src/json/ext/StringEncoder.java +0 -111
- data/java/src/json/ext/Utils.java +0 -88
- data/json-java.gemspec +0 -38
- data/json_pure.gemspec +0 -38
- data/references/rfc7159.txt +0 -899
- data/tools/diff.sh +0 -18
- data/tools/fuzz.rb +0 -131
- data/tools/server.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4ba367cf703870f72ec5de7af43e713095df4b9c88cb0ae12a4c10455052383a
|
4
|
+
data.tar.gz: 622fc0230b9a26ddde47fb3e81c2cf2f0143c22cbfd2429019db1a0f9eef5aaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cab7c9113f03333b720a039fd065d5dd376ab3b4dda1630ccf316ee72121ed4a8abfc06a576be524ce7a86b78e9af917b507fbe95411efef11a563da95295c4
|
7
|
+
data.tar.gz: 68b7cec95107a831286fc3ff36971cd9cc0efbc29157bc0df95a16238b5594214ffca0d417f2dd9011f9e26bf4e163e01e179cbf06f8c053df68c4d60f2416cc
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,71 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
+
## 2020-12-22 (2.5.1)
|
4
|
+
|
5
|
+
* Restore the compatibility for constants of JSON class.
|
6
|
+
|
7
|
+
## 2020-12-22 (2.5.0)
|
8
|
+
|
9
|
+
* Ready to Ractor-safe at Ruby 3.0.
|
10
|
+
|
11
|
+
## 2020-12-17 (2.4.1)
|
12
|
+
|
13
|
+
* Restore version.rb with 2.4.1
|
14
|
+
|
15
|
+
## 2020-12-15 (2.4.0)
|
16
|
+
|
17
|
+
* Implement a freeze: parser option #447
|
18
|
+
* Fix an issue with generate_pretty and empty objects in the Ruby and Java implementations #449
|
19
|
+
* Fix JSON.load_file doc #448
|
20
|
+
* Fix pure parser with unclosed arrays / objects #425
|
21
|
+
* bundle the LICENSE file in the gem #444
|
22
|
+
* Add an option to escape forward slash character #405
|
23
|
+
* RDoc for JSON #439 #446 #442 #434 #433 #430
|
24
|
+
|
25
|
+
## 2020-06-30 (2.3.1)
|
26
|
+
|
27
|
+
* Spelling and grammar fixes for comments. Pull request #191 by Josh
|
28
|
+
Kline.
|
29
|
+
* Enhance generic JSON and #generate docs. Pull request #347 by Victor
|
30
|
+
Shepelev.
|
31
|
+
* Add :nodoc: for GeneratorMethods. Pull request #349 by Victor Shepelev.
|
32
|
+
* Baseline changes to help (JRuby) development. Pull request #371 by Karol
|
33
|
+
Bucek.
|
34
|
+
* Add metadata for rubygems.org. Pull request #379 by Alexandre ZANNI.
|
35
|
+
* Remove invalid JSON.generate description from JSON module rdoc. Pull
|
36
|
+
request #384 by Jeremy Evans.
|
37
|
+
* Test with TruffleRuby in CI. Pull request #402 by Benoit Daloze.
|
38
|
+
* Rdoc enhancements. Pull request #413 by Burdette Lamar.
|
39
|
+
* Fixtures/ are not being tested... Pull request #416 by Marc-André
|
40
|
+
Lafortune.
|
41
|
+
* Use frozen string for hash key. Pull request #420 by Marc-André
|
42
|
+
Lafortune.
|
43
|
+
* Added :call-seq: to RDoc for some methods. Pull request #422 by Burdette
|
44
|
+
Lamar.
|
45
|
+
* Small typo fix. Pull request #423 by Marc-André Lafortune.
|
46
|
+
|
47
|
+
## 2019-12-11 (2.3.0)
|
48
|
+
* Fix default of `create_additions` to always be `false` for `JSON(user_input)`
|
49
|
+
and `JSON.parse(user_input, nil)`.
|
50
|
+
Note that `JSON.load` remains with default `true` and is meant for internal
|
51
|
+
serialization of trusted data. [CVE-2020-10663]
|
52
|
+
* Fix passing args all #to_json in json/add/*.
|
53
|
+
* Fix encoding issues
|
54
|
+
* Fix issues of keyword vs positional parameter
|
55
|
+
* Fix JSON::Parser against bigdecimal updates
|
56
|
+
* Bug fixes to JRuby port
|
57
|
+
|
58
|
+
## 2019-02-21 (2.2.0)
|
59
|
+
* Adds support for 2.6 BigDecimal and ruby standard library Set datetype.
|
60
|
+
|
61
|
+
## 2017-04-18 (2.1.0)
|
62
|
+
* Allow passing of `decimal_class` option to specify a class as which to parse
|
63
|
+
JSON float numbers.
|
64
|
+
## 2017-03-23 (2.0.4)
|
65
|
+
* Raise exception for incomplete unicode surrogates/character escape
|
66
|
+
sequences. This problem was reported by Daniel Gollahon (dgollahon).
|
67
|
+
* Fix arbitrary heap exposure problem. This problem was reported by Ahmad
|
68
|
+
Sherif (ahmadsherif).
|
3
69
|
|
4
70
|
## 2017-01-12 (2.0.3)
|
5
71
|
* Set `required_ruby_version` to 1.9
|
data/Gemfile
CHANGED
@@ -5,12 +5,10 @@ source 'https://rubygems.org'
|
|
5
5
|
case ENV['JSON']
|
6
6
|
when 'ext', nil
|
7
7
|
if ENV['RUBY_ENGINE'] == 'jruby'
|
8
|
-
gemspec :name => 'json
|
8
|
+
gemspec :name => 'json-java'
|
9
9
|
else
|
10
10
|
gemspec :name => 'json'
|
11
11
|
end
|
12
12
|
when 'pure'
|
13
13
|
gemspec :name => 'json_pure'
|
14
14
|
end
|
15
|
-
|
16
|
-
gem 'simplecov'
|
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,5 +1,6 @@
|
|
1
|
-
# JSON implementation for Ruby
|
2
|
-
|
1
|
+
# JSON implementation for Ruby
|
2
|
+
|
3
|
+
[![Travis Widget](http://travis-ci.org/flori/json.svg?branch=master)](https://travis-ci.org/flori/json)
|
3
4
|
|
4
5
|
## Description
|
5
6
|
|
@@ -150,6 +151,18 @@ require 'json/add/rails'
|
|
150
151
|
Both of the additions attempt to require `'json'` (like above) first, if it has
|
151
152
|
not been required yet.
|
152
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
|
+
|
153
166
|
## More Examples
|
154
167
|
|
155
168
|
To create a JSON document from a ruby data structure, you can call
|
@@ -179,14 +192,14 @@ should return a JSON object (a hash converted to JSON with `#to_json`) like
|
|
179
192
|
this (don't forget the `*a` for all the arguments):
|
180
193
|
|
181
194
|
```ruby
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
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
|
190
203
|
```
|
191
204
|
|
192
205
|
The hash key `json_class` is the class, that will be asked to deserialise the
|
@@ -194,26 +207,30 @@ JSON representation later. In this case it's `Range`, but any namespace of
|
|
194
207
|
the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be
|
195
208
|
used to store the necessary data to configure the object to be deserialised.
|
196
209
|
|
197
|
-
If
|
210
|
+
If the key `json_class` is found in a JSON object, the JSON parser checks
|
198
211
|
if the given class responds to the `json_create` class method. If so, it is
|
199
212
|
called with the JSON object converted to a Ruby hash. So a range can
|
200
213
|
be deserialised by implementing `Range.json_create` like this:
|
201
214
|
|
202
215
|
```ruby
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
216
|
+
class Range
|
217
|
+
def self.json_create(o)
|
218
|
+
new(*o['data'])
|
219
|
+
end
|
220
|
+
end
|
208
221
|
```
|
209
222
|
|
210
223
|
Now it possible to serialise/deserialise ranges as well:
|
211
224
|
|
212
225
|
```ruby
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
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]
|
217
234
|
```
|
218
235
|
|
219
236
|
`JSON.generate` always creates the shortest possible string representation of a
|
@@ -373,6 +390,22 @@ Here are the median comparisons for completeness' sake:
|
|
373
390
|
secs/call
|
374
391
|
```
|
375
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
|
+
```
|
408
|
+
|
376
409
|
## Author
|
377
410
|
|
378
411
|
Florian Frank <mailto:flori@ping.de>
|
@@ -389,4 +422,4 @@ The latest version of this library can be downloaded at
|
|
389
422
|
|
390
423
|
Online Documentation should be located at
|
391
424
|
|
392
|
-
*
|
425
|
+
* https://www.rubydoc.info/gems/json
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|