json 2.7.3.rc1-java → 2.7.5-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +16 -1
- data/lib/json/common.rb +6 -1
- data/lib/json/ext/generator/state.rb +5 -5
- data/lib/json/ext.rb +0 -3
- data/lib/json/pure/generator.rb +11 -15
- data/lib/json/pure/parser.rb +14 -14
- data/lib/json/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d3fdaebab78d84d87a9879ef6ec0a84d4b7aee6ee05c89e38901af049c889c4
|
4
|
+
data.tar.gz: 104fe018bcff2685bd814e3c2b4c950ea3754c6c0de6bccb51619856f715a030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58818379e7b2d8e01d18ce12ffbb2c4c90a4c50e6e0128b1470e4dfb01247b210d2e4ca141dbcdbbc2209253229648bed23cab5b86db902ff6a1c00544ba6982
|
7
|
+
data.tar.gz: 82d6865515b4c730a12961884d59feaed0d322da9a41e611f4efbcf053d1bb6d7bc35a5184d1c731bb470d960c982f798aaf7c7bef64de882c29c6f9e6cc867b
|
data/CHANGES.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Changes
|
2
2
|
|
3
|
-
|
3
|
+
### 2024-10-25 (2.7.5)
|
4
|
+
|
5
|
+
* Fix a memory leak when `#to_json` methods raise an exception.
|
6
|
+
* Gracefully handle formatting configs being set to `nil` instead of `""`.
|
7
|
+
* Workaround another issue caused by conflicting versions of both `json_pure` and `json` being loaded.
|
8
|
+
|
9
|
+
### 2024-10-25 (2.7.4)
|
10
|
+
|
11
|
+
* Workaround a bug in 3.4.8 and older https://github.com/rubygems/rubygems/pull/6490.
|
12
|
+
This bug would cause some gems with native extension to fail during compilation.
|
13
|
+
* Workaround different versions of `json` and `json_pure` being loaded (not officially supported).
|
14
|
+
* Make `json_pure` Ractor compatible.
|
15
|
+
|
16
|
+
### 2024-10-24 (2.7.3)
|
17
|
+
|
18
|
+
* Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
|
4
19
|
* Limit the size of ParserError exception messages, only include up to 32 bytes of the unparseable source.
|
5
20
|
* Fix json-pure's `Object#to_json` to accept non state arguments
|
6
21
|
* Fix multiline comment support in `json-pure`.
|
data/lib/json/common.rb
CHANGED
@@ -219,7 +219,12 @@ module JSON
|
|
219
219
|
if opts.nil?
|
220
220
|
Parser.new(source).parse
|
221
221
|
else
|
222
|
-
|
222
|
+
# NB: The ** shouldn't be required, but we have to deal with
|
223
|
+
# different versions of the `json` and `json_pure` gems being
|
224
|
+
# loaded concurrently.
|
225
|
+
# Prior to 2.7.3, `JSON::Ext::Parser` would only take kwargs.
|
226
|
+
# Ref: https://github.com/ruby/json/issues/650
|
227
|
+
Parser.new(source, **opts).parse
|
223
228
|
end
|
224
229
|
end
|
225
230
|
|
@@ -46,15 +46,15 @@ module JSON
|
|
46
46
|
opts.each do |key, value|
|
47
47
|
case key
|
48
48
|
when :indent
|
49
|
-
self.indent = value
|
49
|
+
self.indent = value || ''
|
50
50
|
when :space
|
51
|
-
self.space = value
|
51
|
+
self.space = value || ''
|
52
52
|
when :space_before
|
53
|
-
self.space_before = value
|
53
|
+
self.space_before = value || ''
|
54
54
|
when :array_nl
|
55
|
-
self.array_nl = value
|
55
|
+
self.array_nl = value || ''
|
56
56
|
when :object_nl
|
57
|
-
self.object_nl = value
|
57
|
+
self.object_nl = value || ''
|
58
58
|
when :max_nesting
|
59
59
|
self.max_nesting = value || 0
|
60
60
|
when :depth
|
data/lib/json/ext.rb
CHANGED
@@ -15,9 +15,6 @@ module JSON
|
|
15
15
|
else
|
16
16
|
require 'json/ext/parser'
|
17
17
|
require 'json/ext/generator'
|
18
|
-
unless RUBY_ENGINE == 'jruby'
|
19
|
-
require 'json/ext/generator/state'
|
20
|
-
end
|
21
18
|
$DEBUG and warn "Using Ext extension for JSON."
|
22
19
|
JSON.parser = Parser
|
23
20
|
JSON.generator = Generator
|
data/lib/json/pure/generator.rb
CHANGED
@@ -50,8 +50,7 @@ module JSON
|
|
50
50
|
# Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
|
51
51
|
# UTF16 big endian characters as \u????, and return it.
|
52
52
|
def utf8_to_json(string, script_safe = false) # :nodoc:
|
53
|
-
string = string.
|
54
|
-
string.force_encoding(::Encoding::ASCII_8BIT)
|
53
|
+
string = string.b
|
55
54
|
if script_safe
|
56
55
|
string.gsub!(SCRIPT_SAFE_ESCAPE_PATTERN) { SCRIPT_SAFE_MAP[$&] || $& }
|
57
56
|
else
|
@@ -62,8 +61,7 @@ module JSON
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def utf8_to_json_ascii(string, script_safe = false) # :nodoc:
|
65
|
-
string = string.
|
66
|
-
string.force_encoding(::Encoding::ASCII_8BIT)
|
64
|
+
string = string.b
|
67
65
|
map = script_safe ? SCRIPT_SAFE_MAP : MAP
|
68
66
|
string.gsub!(/[\/"\\\x0-\x1f]/n) { map[$&] || $& }
|
69
67
|
string.gsub!(/(
|
@@ -241,13 +239,13 @@ module JSON
|
|
241
239
|
end
|
242
240
|
|
243
241
|
# NOTE: If adding new instance variables here, check whether #generate should check them for #generate_json
|
244
|
-
@indent = opts[:indent] if opts.key?(:indent)
|
245
|
-
@space = opts[:space] if opts.key?(:space)
|
246
|
-
@space_before = opts[:space_before] if opts.key?(:space_before)
|
247
|
-
@object_nl = opts[:object_nl] if opts.key?(:object_nl)
|
248
|
-
@array_nl = opts[:array_nl] if opts.key?(:array_nl)
|
249
|
-
@allow_nan = !!opts[:allow_nan]
|
250
|
-
@ascii_only = opts[:ascii_only]
|
242
|
+
@indent = opts[:indent] || '' if opts.key?(:indent)
|
243
|
+
@space = opts[:space] || '' if opts.key?(:space)
|
244
|
+
@space_before = opts[:space_before] || '' if opts.key?(:space_before)
|
245
|
+
@object_nl = opts[:object_nl] || '' if opts.key?(:object_nl)
|
246
|
+
@array_nl = opts[:array_nl] || '' if opts.key?(:array_nl)
|
247
|
+
@allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
|
248
|
+
@ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
|
251
249
|
@depth = opts[:depth] || 0
|
252
250
|
@buffer_initial_length ||= opts[:buffer_initial_length]
|
253
251
|
|
@@ -409,16 +407,14 @@ module JSON
|
|
409
407
|
|
410
408
|
def json_transform(state)
|
411
409
|
delim = ",#{state.object_nl}"
|
412
|
-
result = "{#{state.object_nl}"
|
413
|
-
result = result.dup if result.frozen? # RUBY_VERSION < 3.0
|
410
|
+
result = +"{#{state.object_nl}"
|
414
411
|
depth = state.depth += 1
|
415
412
|
first = true
|
416
413
|
indent = !state.object_nl.empty?
|
417
414
|
each { |key, value|
|
418
415
|
result << delim unless first
|
419
416
|
result << state.indent * depth if indent
|
420
|
-
result = "#{result}#{key.to_s.to_json(state)}#{state.space_before}:#{state.space}"
|
421
|
-
result = result.dup if result.frozen? # RUBY_VERSION < 3.0
|
417
|
+
result = +"#{result}#{key.to_s.to_json(state)}#{state.space_before}:#{state.space}"
|
422
418
|
if state.strict? && !(false == value || true == value || nil == value || String === value || Array === value || Hash === value || Integer === value || Float === value)
|
423
419
|
raise GeneratorError, "#{value.class} not allowed in JSON"
|
424
420
|
elsif value.respond_to?(:to_json)
|
data/lib/json/pure/parser.rb
CHANGED
@@ -148,25 +148,25 @@ module JSON
|
|
148
148
|
end
|
149
149
|
|
150
150
|
# Unescape characters in strings.
|
151
|
-
UNESCAPE_MAP =
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
})
|
151
|
+
UNESCAPE_MAP = {
|
152
|
+
'"' => '"',
|
153
|
+
'\\' => '\\',
|
154
|
+
'/' => '/',
|
155
|
+
'b' => "\b",
|
156
|
+
'f' => "\f",
|
157
|
+
'n' => "\n",
|
158
|
+
'r' => "\r",
|
159
|
+
't' => "\t",
|
160
|
+
'u' => nil,
|
161
|
+
}.freeze
|
163
162
|
|
164
163
|
STR_UMINUS = ''.respond_to?(:-@)
|
165
164
|
def parse_string
|
166
165
|
if scan(STRING)
|
167
166
|
return '' if self[1].empty?
|
168
|
-
string = self[1].gsub(%r(
|
169
|
-
|
167
|
+
string = self[1].gsub(%r{(?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff])}n) do |c|
|
168
|
+
k = $&[1]
|
169
|
+
if u = UNESCAPE_MAP.fetch(k) { k.chr }
|
170
170
|
u
|
171
171
|
else # \uXXXX
|
172
172
|
bytes = ''.b
|
data/lib/json/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.5
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Daniel Luz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A JSON implementation as a JRuby extension.
|
14
14
|
email: dev+ruby@mernen.com
|
@@ -71,9 +71,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: '2.3'
|
72
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubygems_version: 3.3.26
|
79
79
|
signing_key:
|