json_pure 2.7.3 → 2.7.5
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 +4 -4
- data/CHANGES.md +13 -0
- data/lib/json/common.rb +6 -1
- data/lib/json/ext.rb +0 -3
- data/lib/json/pure/generator.rb +7 -7
- data/lib/json/pure/parser.rb +14 -14
- data/lib/json/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 859e40f5bfa7da73a90576204b5c49d6f42b9f2ca903239ecea54ec7a781fdc4
|
4
|
+
data.tar.gz: e38d6c5db98da6416dbb75746621aa7b7d3bd7e8f8c62042eef6e15e9ecf5f65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3569ecd696382dbf173955fcfa9f49f3452a2d8b45bf29dcad6cd22ee0ac67bc8a6359ca548ae5367ca93cd02af4515b7e35ac213b5989658ad3133815fbece3
|
7
|
+
data.tar.gz: 6a23ba9fba6317c04f58c0d03a81b9d85aa8c2f5f8ec585cdfe9b6e97dc5f7994cfb3ef52749b4575857057f1cf803fb29936571f0d20f7b99e17828fa7d954b
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changes
|
2
2
|
|
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
|
+
|
3
16
|
### 2024-10-24 (2.7.3)
|
4
17
|
|
5
18
|
* Numerous performance optimizations in `JSON.generate` and `JSON.dump` (up to 2 times faster).
|
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
|
|
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
@@ -239,13 +239,13 @@ module JSON
|
|
239
239
|
end
|
240
240
|
|
241
241
|
# NOTE: If adding new instance variables here, check whether #generate should check them for #generate_json
|
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]
|
248
|
-
@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)
|
249
249
|
@depth = opts[:depth] || 0
|
250
250
|
@buffer_initial_length ||= opts[:buffer_initial_length]
|
251
251
|
|
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_pure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
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: This is a JSON implementation in pure Ruby.
|
14
14
|
email: flori@ping.de
|