json 3.0.0.rc1-java → 3.0.1-java
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 +11 -2
- data/lib/json/common.rb +68 -11
- data/lib/json/ext/generator.jar +0 -0
- data/lib/json/ext/parser.jar +0 -0
- 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: 6172ab55daf2cd89c12ee78ff4262de865bd7dfd20f40ad8669353b78ebaa8d8
|
|
4
|
+
data.tar.gz: c87e0ad55b7637f1d691af7bae9ec9c261622aa49b1c66bd3cb80d5a0e6b9c1b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 26761f2f23036bc7aa235eb016d2fe28eac9a21b5c4efae05a987a7461550f356c9d7435f59b87646cb15b9383e04e42e9211354a9d1e6c7be4847c835b85be6
|
|
7
|
+
data.tar.gz: 5f5825feaa01223c314de88082508f6928e5171cb65114d8ed51b2636c546a078fbce9294a6baec61d0058492638c89fe110745add121cf14d87fb1d494eb1f7
|
data/CHANGES.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
### Unreleased
|
|
4
4
|
|
|
5
|
+
### 2026-09-08 (3.0.1)
|
|
6
|
+
|
|
7
|
+
* Restore the `limit` positional argument of `JSON.dump`.
|
|
8
|
+
|
|
9
|
+
### 2026-09-07 (3.0.0)
|
|
10
|
+
|
|
11
|
+
* Add `JSON::ParserError#json_path` to locate parse errors in the document as a JSONPath-style string (e.g. `$.foo[0].bar`). For duplicate key errors it points at the duplicated key itself.
|
|
12
|
+
* Fix the parser to also reject lone trailing UTF-16 surrogates (`\uDCxx` with no leading partner), symmetric to the leading-surrogate case. The Java parser already rejected these; this closes the CRuby/JRuby parity gap.
|
|
13
|
+
|
|
5
14
|
### 2026-08-11 (3.0.0.rc1)
|
|
6
15
|
|
|
7
16
|
With the removal of the insecure `create_additions` option, `JSON.load` and `JSON.dump` are
|
|
@@ -24,8 +33,8 @@ JavaScript comments in documents are no longer supported by default.
|
|
|
24
33
|
Numerous rarely used aliases have been removed.
|
|
25
34
|
|
|
26
35
|
* `JSON.load` defaults are now safe to use.
|
|
27
|
-
* All unknown options
|
|
28
|
-
* The `allow_comments` parsing option now
|
|
36
|
+
* All unknown options will now cause an `ArgumentError` rather than to be ignored.
|
|
37
|
+
* The `allow_comments` parsing option now defaults to `false`.
|
|
29
38
|
* The `allow_duplicate_key` option now defaults to `false`, for both parsing and generating JSON.
|
|
30
39
|
* Removed the `limit` positional argument of `JSON.dump`.
|
|
31
40
|
* Removed the `escape_slash` alias of `script_safe`.
|
data/lib/json/common.rb
CHANGED
|
@@ -142,7 +142,56 @@ module JSON
|
|
|
142
142
|
|
|
143
143
|
# This exception is raised if a parser error occurs.
|
|
144
144
|
class ParserError < JSONError
|
|
145
|
-
|
|
145
|
+
# Line number where the parser encountered an error.
|
|
146
|
+
# Is <tt>nil</tt> when raised by JSON::ResumableParser.
|
|
147
|
+
attr_reader :line
|
|
148
|
+
|
|
149
|
+
# Column number where the parser encountered an error.
|
|
150
|
+
# Is <tt>nil</tt> when raised by JSON::ResumableParser.
|
|
151
|
+
attr_reader :column
|
|
152
|
+
|
|
153
|
+
# Returns a best effort JSONPath string representing where in the document
|
|
154
|
+
# the parser encountered an error:
|
|
155
|
+
#
|
|
156
|
+
# begin
|
|
157
|
+
# JSON.parse('{"articles": [ { "title": invalid } ]}')
|
|
158
|
+
# rescue JSON::ParserError => error
|
|
159
|
+
# error.json_path # => "$.articles[0].title"
|
|
160
|
+
# end
|
|
161
|
+
def json_path
|
|
162
|
+
return @json_path if String === @json_path
|
|
163
|
+
|
|
164
|
+
if Array === @json_path
|
|
165
|
+
path = build_json_path(@json_path)
|
|
166
|
+
@json_path = path unless frozen?
|
|
167
|
+
return path
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
private
|
|
172
|
+
|
|
173
|
+
def build_json_path(segments)
|
|
174
|
+
error = false
|
|
175
|
+
path = segments.filter_map do |segment|
|
|
176
|
+
next if error
|
|
177
|
+
|
|
178
|
+
case segment
|
|
179
|
+
when Integer
|
|
180
|
+
"[#{segment}]"
|
|
181
|
+
when String, Symbol
|
|
182
|
+
if segment.match?(/\A[a-zA-Z\$\_][a-zA-Z\$\_0-9]*\z/)
|
|
183
|
+
".#{segment}"
|
|
184
|
+
else
|
|
185
|
+
segment = segment.to_s.gsub(/["\\]/, { '"' => '\\"', '\\' => '\\\\' })
|
|
186
|
+
%{["#{segment}"]}
|
|
187
|
+
end
|
|
188
|
+
else
|
|
189
|
+
error = true
|
|
190
|
+
nil
|
|
191
|
+
end
|
|
192
|
+
end.join
|
|
193
|
+
"$#{path}".freeze
|
|
194
|
+
end
|
|
146
195
|
end
|
|
147
196
|
|
|
148
197
|
# This exception is raised if the nesting of parsed data structures is too
|
|
@@ -677,16 +726,14 @@ module JSON
|
|
|
677
726
|
end
|
|
678
727
|
|
|
679
728
|
# :call-seq:
|
|
680
|
-
# JSON.dump(obj, io = nil, options = nil)
|
|
729
|
+
# JSON.dump(obj, io = nil, _deprecated_limit = nil, options = nil)
|
|
681
730
|
#
|
|
682
731
|
# Dumps +obj+ as a \JSON string, i.e. calls generate on the object and returns the result.
|
|
683
732
|
#
|
|
684
|
-
# The default options can be changed via method JSON.dump_default_options.
|
|
685
|
-
#
|
|
686
733
|
# - Argument +io+, if given, should respond to method +write+;
|
|
687
734
|
# the \JSON \String is written to +io+, and +io+ is returned.
|
|
688
735
|
# If +io+ is not given, the \JSON \String is returned.
|
|
689
|
-
#
|
|
736
|
+
# - Argument +_deprecated_limit+ is deprecated, pass the +:max_nesting+ option instead.
|
|
690
737
|
# ---
|
|
691
738
|
#
|
|
692
739
|
# When argument +io+ is not given, returns the \JSON \String generated from +obj+:
|
|
@@ -702,21 +749,31 @@ module JSON
|
|
|
702
749
|
# puts File.read(path)
|
|
703
750
|
# Output:
|
|
704
751
|
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
|
|
705
|
-
def dump(obj, anIO = nil, kwargs = nil)
|
|
752
|
+
def dump(obj, anIO = nil, _deprecated_limit = nil, kwargs = nil)
|
|
706
753
|
if kwargs.nil?
|
|
707
|
-
if
|
|
708
|
-
|
|
709
|
-
|
|
754
|
+
if _deprecated_limit.nil?
|
|
755
|
+
if anIO.is_a?(Hash)
|
|
756
|
+
kwargs = anIO
|
|
757
|
+
anIO = nil
|
|
758
|
+
end
|
|
759
|
+
elsif _deprecated_limit.is_a?(Hash)
|
|
760
|
+
kwargs = _deprecated_limit
|
|
761
|
+
_deprecated_limit = nil
|
|
710
762
|
end
|
|
711
763
|
end
|
|
712
764
|
|
|
713
|
-
|
|
714
|
-
|
|
765
|
+
unless anIO.nil?
|
|
766
|
+
if anIO.respond_to?(:to_io)
|
|
767
|
+
anIO = anIO.to_io
|
|
768
|
+
elsif _deprecated_limit.nil? && !anIO.respond_to?(:write)
|
|
769
|
+
anIO, _deprecated_limit = nil, anIO
|
|
770
|
+
end
|
|
715
771
|
end
|
|
716
772
|
|
|
717
773
|
opts = {
|
|
718
774
|
allow_nan: true,
|
|
719
775
|
}
|
|
776
|
+
opts[:max_nesting] = _deprecated_limit if _deprecated_limit
|
|
720
777
|
opts.merge!(kwargs) if kwargs
|
|
721
778
|
|
|
722
779
|
State.generate(obj, opts, anIO)
|
data/lib/json/ext/generator.jar
CHANGED
|
Binary file
|
data/lib/json/ext/parser.jar
CHANGED
|
Binary file
|
data/lib/json/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: json
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.1
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Luz
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-08
|
|
10
|
+
date: 2026-09-08 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: A JSON implementation as a JRuby extension.
|
|
13
13
|
email: dev+ruby@mernen.com
|