json-repair 0.34.0__py3-none-any.whl → 0.36.0__py3-none-any.whl
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.
- json_repair/json_parser.py +36 -0
- {json_repair-0.34.0.dist-info → json_repair-0.36.0.dist-info}/METADATA +2 -2
- {json_repair-0.34.0.dist-info → json_repair-0.36.0.dist-info}/RECORD +7 -7
- {json_repair-0.34.0.dist-info → json_repair-0.36.0.dist-info}/WHEEL +1 -1
- {json_repair-0.34.0.dist-info → json_repair-0.36.0.dist-info}/LICENSE +0 -0
- {json_repair-0.34.0.dist-info → json_repair-0.36.0.dist-info}/entry_points.txt +0 -0
- {json_repair-0.34.0.dist-info → json_repair-0.36.0.dist-info}/top_level.txt +0 -0
json_repair/json_parser.py
CHANGED
@@ -223,6 +223,10 @@ class JSONParser:
|
|
223
223
|
"While parsing an array we missed the closing ], adding it back",
|
224
224
|
)
|
225
225
|
self.index -= 1
|
226
|
+
# Add the missing closing bracket
|
227
|
+
self.json_str = (
|
228
|
+
self.json_str[: self.index + 1] + "]" + self.json_str[self.index + 1 :]
|
229
|
+
)
|
226
230
|
|
227
231
|
self.index += 1
|
228
232
|
self.context.reset()
|
@@ -443,6 +447,38 @@ class JSONParser:
|
|
443
447
|
string_acc += escape_seqs.get(char, char) or char
|
444
448
|
self.index += 1
|
445
449
|
char = self.get_char_at()
|
450
|
+
# If we are in object key context and we find a colon, it could be a missing right quote
|
451
|
+
if (
|
452
|
+
char == ":"
|
453
|
+
and not missing_quotes
|
454
|
+
and self.context.current == ContextValues.OBJECT_KEY
|
455
|
+
):
|
456
|
+
# Ok now we need to check if this is followed by a value like "..."
|
457
|
+
i = self.skip_to_character(character=lstring_delimiter, idx=1)
|
458
|
+
next_c = self.get_char_at(i)
|
459
|
+
if next_c:
|
460
|
+
i += 1
|
461
|
+
# found the first delimiter
|
462
|
+
i = self.skip_to_character(character=rstring_delimiter, idx=i)
|
463
|
+
next_c = self.get_char_at(i)
|
464
|
+
if next_c:
|
465
|
+
# found a second delimiter
|
466
|
+
i += 1
|
467
|
+
# Skip spaces
|
468
|
+
i = self.skip_whitespaces_at(idx=i, move_main_index=False)
|
469
|
+
next_c = self.get_char_at(i)
|
470
|
+
if next_c and next_c in [",", "}"]:
|
471
|
+
# Ok then this is a missing right quote
|
472
|
+
self.log(
|
473
|
+
"While parsing a string missing the right delimiter in object key context, we found a :, stopping here",
|
474
|
+
)
|
475
|
+
break
|
476
|
+
else:
|
477
|
+
# The string ended without finding a lstring_delimiter, I will assume this is a missing right quote
|
478
|
+
self.log(
|
479
|
+
"While parsing a string missing the right delimiter in object key context, we found a :, stopping here",
|
480
|
+
)
|
481
|
+
break
|
446
482
|
# ChatGPT sometimes forget to quote stuff in html tags or markdown, so we do this whole thing here
|
447
483
|
if char == rstring_delimiter:
|
448
484
|
# Special case here, in case of double quotes one after another
|
@@ -1,13 +1,13 @@
|
|
1
1
|
json_repair/__init__.py,sha256=c4L2kZrHvWEKfj_ODU2naliNuvU6FlFVxtF0hbLe6s8,178
|
2
2
|
json_repair/__main__.py,sha256=EsJb-y89uZEvGQQg1GdIDWzfDwfOMvVekKEtdguQXCM,67
|
3
3
|
json_repair/json_context.py,sha256=mm6dOyrPJ1sDskTORZSXCW7W9-5veMlUKqXQ3Hw3EG4,971
|
4
|
-
json_repair/json_parser.py,sha256=
|
4
|
+
json_repair/json_parser.py,sha256=yYNqYR67rsYTJJySranMMAZ6_VMRRfX0-VzYV1gMXYE,35759
|
5
5
|
json_repair/json_repair.py,sha256=LINLSJBs3cJMfs1YRDaIpfWR5PJLs87Oe06G5yQjY18,9729
|
6
6
|
json_repair/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
json_repair/string_file_wrapper.py,sha256=koZmdq2-Z5K7XF1bDqX6dEbNaVMJYcMTjq-aGe6NQvA,4526
|
8
|
-
json_repair-0.
|
9
|
-
json_repair-0.
|
10
|
-
json_repair-0.
|
11
|
-
json_repair-0.
|
12
|
-
json_repair-0.
|
13
|
-
json_repair-0.
|
8
|
+
json_repair-0.36.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
9
|
+
json_repair-0.36.0.dist-info/METADATA,sha256=5Hx3m-y1Ay7nOmhAsgYR-WH-a7NHMrpg4EJoRCCy49c,11794
|
10
|
+
json_repair-0.36.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
11
|
+
json_repair-0.36.0.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
|
12
|
+
json_repair-0.36.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
13
|
+
json_repair-0.36.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|