json-repair 0.14.0 → 0.15.0
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/CHANGELOG.md +18 -0
- data/lib/json/repair/version.rb +1 -1
- data/lib/json/repairer.rb +23 -2
- data/sig/json/repairer.rbs +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc8c6dfaa0c00f4f8dcf62be1f5bd925fe1af4b0649a7986bf4354f85f1d27bd
|
|
4
|
+
data.tar.gz: dd91d930dfe19c7796e02898202e51b9cd573b0af51c632c975689a2882e2851
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5db30ce96f442ae57ff311a93481f9c991be8b3b13e45042d9abdd6a9f0562e0a43ef2eafaf40095528104f59bee7e19753b03e4376ac170071d83f66fe1c2ca
|
|
7
|
+
data.tar.gz: 3a4129cc0b8faefa3ded17ea4f3440d623bcc7972444dd2cd2d0a2f0884fcb1059017059599962370b44e2677a45e2ad8862bdf7174cc99487ff9566745fd010
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
### 2026-06-17 (0.15.0)
|
|
4
|
+
|
|
5
|
+
* Repair elided empty array slots: `[1,,2]` → `[1,2]`, `[1,,,,2]` →
|
|
6
|
+
`[1,2]`, `[1, ,2]` → `[1,2]`, and `[,,1]` → `[1]`. A comma with no
|
|
7
|
+
value between it and the previous one (or the opening bracket) marks
|
|
8
|
+
an empty slot, which is dropped — uniformly extending the existing
|
|
9
|
+
single-leading-comma repair (`[,1]` → `[1]`) to repeated and interior
|
|
10
|
+
positions, and consistent with `dirty-json`. Divergence from upstream
|
|
11
|
+
[jsonrepair](https://github.com/josdejong/jsonrepair), which as of
|
|
12
|
+
v3.14.0 mangles `[1,,2]`/`[,,1]` into `[[1],2]`/`[[],1]` (its root
|
|
13
|
+
comma-sequence wrap misfires) and raises on `[1,,,,2]`; commented at
|
|
14
|
+
the site. Arrays only: an elided comma in an object
|
|
15
|
+
(`{"a":1,,"b":2}`) still raises rather than guessing a missing key —
|
|
16
|
+
there is no data to mangle, so the clean error is kept (and pinned in
|
|
17
|
+
the spec). Differential vs main over a comma grid: every change is an
|
|
18
|
+
array with elided commas going from mangle/raise to a correct drop,
|
|
19
|
+
with objects and all non-elided shapes unchanged. Benchmarks flat.
|
|
20
|
+
|
|
3
21
|
### 2026-06-17 (0.14.0)
|
|
4
22
|
|
|
5
23
|
* Repair a leading `+` on numbers, like in JSON5: `+1.23` → `1.23`,
|
data/lib/json/repair/version.rb
CHANGED
data/lib/json/repairer.rb
CHANGED
|
@@ -434,6 +434,24 @@ module JSON
|
|
|
434
434
|
end
|
|
435
435
|
end
|
|
436
436
|
|
|
437
|
+
# Repair elided empty array slots like [1,,2] or [1,,,,2]. Called both
|
|
438
|
+
# at the start of an array (leading commas) and right after a separator
|
|
439
|
+
# comma: skip every comma found here (each marks a slot with no value
|
|
440
|
+
# between it and the previous one or the opening bracket), so [1,,2] ->
|
|
441
|
+
# [1,2], [1,,,,2] -> [1,2], and [,,1] -> [1]. Dropping the slot — rather
|
|
442
|
+
# than inserting null — extends the single-leading-comma repair ([,1] ->
|
|
443
|
+
# [1]) uniformly. Divergence from upstream, which mangles [1,,2] into
|
|
444
|
+
# [[1],2] via its root comma-sequence wrap and raises on [1,,,,2] (as of
|
|
445
|
+
# v3.14.0).
|
|
446
|
+
def skip_elided_commas
|
|
447
|
+
loop do
|
|
448
|
+
parse_whitespace_and_skip_comments
|
|
449
|
+
break unless @json[@index] == COMMA
|
|
450
|
+
|
|
451
|
+
@index += 1
|
|
452
|
+
end
|
|
453
|
+
end
|
|
454
|
+
|
|
437
455
|
# Parse a string enclosed by double quotes "...". Can contain escaped quotes
|
|
438
456
|
# Repair strings enclosed in single quotes or special quotes
|
|
439
457
|
# Repair an escaped string
|
|
@@ -845,8 +863,9 @@ module JSON
|
|
|
845
863
|
@index += 1
|
|
846
864
|
parse_whitespace_and_skip_comments
|
|
847
865
|
|
|
848
|
-
# repair: skip leading
|
|
849
|
-
|
|
866
|
+
# repair: skip leading commas (elided empty slots) like [,1,2,3]
|
|
867
|
+
# or [,,1] — the same drop applied after a separator comma below
|
|
868
|
+
skip_elided_commas
|
|
850
869
|
|
|
851
870
|
initial = true
|
|
852
871
|
while @index < @json.length && @json[@index] != CLOSING_BRACKET
|
|
@@ -857,6 +876,8 @@ module JSON
|
|
|
857
876
|
processed_comma = parse_character(COMMA)
|
|
858
877
|
# repair missing comma
|
|
859
878
|
@output = insert_before_last_whitespace(@output, ',') unless processed_comma
|
|
879
|
+
# repair: drop elided empty slots like [1,,2] -> [1,2]
|
|
880
|
+
skip_elided_commas if processed_comma
|
|
860
881
|
end
|
|
861
882
|
|
|
862
883
|
skip_ellipsis
|
data/sig/json/repairer.rbs
CHANGED
|
@@ -66,6 +66,9 @@ module JSON
|
|
|
66
66
|
# or a similar construct in objects.
|
|
67
67
|
def skip_ellipsis: () -> void
|
|
68
68
|
|
|
69
|
+
# Drop elided empty array slots like [1,,2] -> [1,2].
|
|
70
|
+
def skip_elided_commas: () -> void
|
|
71
|
+
|
|
69
72
|
# Parse a string enclosed by double quotes "...". Can contain escaped quotes
|
|
70
73
|
# Repair strings enclosed in single quotes or special quotes
|
|
71
74
|
# Repair an escaped string
|