json 2.14.1-java → 2.15.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 +10 -0
- data/README.md +3 -1
- data/lib/json/ext/generator.jar +0 -0
- data/lib/json/ext/parser.jar +0 -0
- data/lib/json/truffle_ruby/generator.rb +21 -13
- 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: c9c9f896105222f17d7561710f916b6dd6ceb760e3d9ac17a778159954a3cd4d
|
4
|
+
data.tar.gz: 551c43c7e7f71d3c849d4b6af1a3542665b21732e2f5114631163d789cde7c92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb15c44e7a4372de8f9aed4ec69f4070bffdd9311e32606b91d81b3326ff343e5d64d5346f3a604be0f83ce623ba13d45ea63ace209ba9bc47f758dcc7d8e05f
|
7
|
+
data.tar.gz: a9c67ce3cdc6faf65fc8467d043bf9907d58933bdff9131b184ee29d735277a88d597846c04bcbe1ae3e2990aca62c8b19e6b90307c16bdd69b7b2b863166b29
|
data/CHANGES.md
CHANGED
@@ -2,6 +2,15 @@
|
|
2
2
|
|
3
3
|
### Unreleased
|
4
4
|
|
5
|
+
### 2025-10-07 (2.15.1)
|
6
|
+
|
7
|
+
* Fix incorrect escaping in the JRuby extension when encoding shared strings.
|
8
|
+
|
9
|
+
### 2025-09-22 (2.15.0)
|
10
|
+
|
11
|
+
* `JSON::Coder` callback now receive a second argument to convey whether the object is a hash key.
|
12
|
+
* Tuned the floating point number generator to not use scientific notation as aggressively.
|
13
|
+
|
5
14
|
### 2025-09-18 (2.14.1)
|
6
15
|
|
7
16
|
* Fix `IndexOutOfBoundsException` in the JRuby extension when encoding shared strings.
|
@@ -23,6 +32,7 @@
|
|
23
32
|
* Fix `JSON::Coder` to also invoke block for hash keys that aren't strings nor symbols.
|
24
33
|
* Fix `JSON.unsafe_load` usage with proc
|
25
34
|
* Fix the parser to more consistently reject invalid UTF-16 surogate pairs.
|
35
|
+
* Stop defining `String.json_create`, `String#to_json_raw`, `String#to_json_raw_object` when `json/add` isn't loaded.
|
26
36
|
|
27
37
|
### 2025-07-28 (2.13.2)
|
28
38
|
|
data/README.md
CHANGED
@@ -97,7 +97,7 @@ Instead it is recommended to use the newer `JSON::Coder` API:
|
|
97
97
|
|
98
98
|
```ruby
|
99
99
|
module MyApp
|
100
|
-
API_JSON_CODER = JSON::Coder.new do |object|
|
100
|
+
API_JSON_CODER = JSON::Coder.new do |object, is_object_key|
|
101
101
|
case object
|
102
102
|
when Time
|
103
103
|
object.iso8601(3)
|
@@ -113,6 +113,8 @@ puts MyApp::API_JSON_CODER.dump(Time.now.utc) # => "2025-01-21T08:41:44.286Z"
|
|
113
113
|
The provided block is called for all objects that don't have a native JSON equivalent, and
|
114
114
|
must return a Ruby object that has a native JSON equivalent.
|
115
115
|
|
116
|
+
It is also called for objects that do have a JSON equivalent, but are used as Hash keys, for instance `{ 1 => 2}`.
|
117
|
+
|
116
118
|
## Combining JSON fragments
|
117
119
|
|
118
120
|
To combine JSON fragments into a bigger JSON document, you can use `JSON::Fragment`:
|
data/lib/json/ext/generator.jar
CHANGED
Binary file
|
data/lib/json/ext/parser.jar
CHANGED
Binary file
|
@@ -47,6 +47,14 @@ module JSON
|
|
47
47
|
|
48
48
|
SCRIPT_SAFE_ESCAPE_PATTERN = /[\/"\\\x0-\x1f\u2028-\u2029]/
|
49
49
|
|
50
|
+
def self.native_type?(value) # :nodoc:
|
51
|
+
(false == value || true == value || nil == value || String === value || Array === value || Hash === value || Integer === value || Float === value || Fragment === value)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.native_key?(key) # :nodoc:
|
55
|
+
(Symbol === key || String === key)
|
56
|
+
end
|
57
|
+
|
50
58
|
# Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
|
51
59
|
# UTF16 big endian characters as \u????, and return it.
|
52
60
|
def self.utf8_to_json(string, script_safe = false) # :nodoc:
|
@@ -448,10 +456,10 @@ module JSON
|
|
448
456
|
state = State.from_state(state) if state
|
449
457
|
if state&.strict?
|
450
458
|
value = self
|
451
|
-
if state.strict? && !(
|
459
|
+
if state.strict? && !Generator.native_type?(value)
|
452
460
|
if state.as_json
|
453
|
-
value = state.as_json.call(value)
|
454
|
-
unless
|
461
|
+
value = state.as_json.call(value, false)
|
462
|
+
unless Generator.native_type?(value)
|
455
463
|
raise GeneratorError.new("#{value.class} returned by #{state.as_json} not allowed in JSON", value)
|
456
464
|
end
|
457
465
|
value.to_json(state)
|
@@ -509,12 +517,12 @@ module JSON
|
|
509
517
|
end
|
510
518
|
result << state.indent * depth if indent
|
511
519
|
|
512
|
-
if state.strict? && !(
|
520
|
+
if state.strict? && !Generator.native_key?(key)
|
513
521
|
if state.as_json
|
514
|
-
key = state.as_json.call(key)
|
522
|
+
key = state.as_json.call(key, true)
|
515
523
|
end
|
516
524
|
|
517
|
-
unless
|
525
|
+
unless Generator.native_key?(key)
|
518
526
|
raise GeneratorError.new("#{key.class} not allowed as object key in JSON", value)
|
519
527
|
end
|
520
528
|
end
|
@@ -527,10 +535,10 @@ module JSON
|
|
527
535
|
end
|
528
536
|
|
529
537
|
result = +"#{result}#{key_json}#{state.space_before}:#{state.space}"
|
530
|
-
if state.strict? && !(
|
538
|
+
if state.strict? && !Generator.native_type?(value)
|
531
539
|
if state.as_json
|
532
|
-
value = state.as_json.call(value)
|
533
|
-
unless
|
540
|
+
value = state.as_json.call(value, false)
|
541
|
+
unless Generator.native_type?(value)
|
534
542
|
raise GeneratorError.new("#{value.class} returned by #{state.as_json} not allowed in JSON", value)
|
535
543
|
end
|
536
544
|
result << value.to_json(state)
|
@@ -588,10 +596,10 @@ module JSON
|
|
588
596
|
each { |value|
|
589
597
|
result << delim unless first
|
590
598
|
result << state.indent * depth if indent
|
591
|
-
if state.strict? && !(
|
599
|
+
if state.strict? && !Generator.native_type?(value)
|
592
600
|
if state.as_json
|
593
|
-
value = state.as_json.call(value)
|
594
|
-
unless
|
601
|
+
value = state.as_json.call(value, false)
|
602
|
+
unless Generator.native_type?(value)
|
595
603
|
raise GeneratorError.new("#{value.class} returned by #{state.as_json} not allowed in JSON", value)
|
596
604
|
end
|
597
605
|
result << value.to_json(state)
|
@@ -625,7 +633,7 @@ module JSON
|
|
625
633
|
if state.allow_nan?
|
626
634
|
to_s
|
627
635
|
elsif state.strict? && state.as_json
|
628
|
-
casted_value = state.as_json.call(self)
|
636
|
+
casted_value = state.as_json.call(self, false)
|
629
637
|
|
630
638
|
if casted_value.equal?(self)
|
631
639
|
raise GeneratorError.new("#{self} not allowed in JSON", self)
|
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.
|
4
|
+
version: 2.15.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Daniel Luz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-10-07 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
|