json-repair 0.29.5__py3-none-any.whl → 0.29.6__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 +19 -19
- {json_repair-0.29.5.dist-info → json_repair-0.29.6.dist-info}/METADATA +1 -1
- {json_repair-0.29.5.dist-info → json_repair-0.29.6.dist-info}/RECORD +7 -7
- {json_repair-0.29.5.dist-info → json_repair-0.29.6.dist-info}/LICENSE +0 -0
- {json_repair-0.29.5.dist-info → json_repair-0.29.6.dist-info}/WHEEL +0 -0
- {json_repair-0.29.5.dist-info → json_repair-0.29.6.dist-info}/entry_points.txt +0 -0
- {json_repair-0.29.5.dist-info → json_repair-0.29.6.dist-info}/top_level.txt +0 -0
json_repair/json_parser.py
CHANGED
@@ -308,9 +308,6 @@ class JSONParser:
|
|
308
308
|
rstring_delimiter_missing = True
|
309
309
|
# check if this is a case in which the closing comma is NOT missing instead
|
310
310
|
i = self.skip_to_character(character=rstring_delimiter, idx=1)
|
311
|
-
# If the rstring_delimeter is escaped then it's not what we are looking for
|
312
|
-
while self.get_char_at(i - 1) == "\\":
|
313
|
-
i = self.skip_to_character(character=rstring_delimiter, idx=i + 1)
|
314
311
|
next_c = self.get_char_at(i)
|
315
312
|
if next_c:
|
316
313
|
i += 1
|
@@ -319,6 +316,15 @@ class JSONParser:
|
|
319
316
|
next_c = self.get_char_at(i)
|
320
317
|
if next_c and next_c in [",", "}"]:
|
321
318
|
rstring_delimiter_missing = False
|
319
|
+
elif char == ",":
|
320
|
+
# We couldn't find any rstring_delimeter before the end of the string
|
321
|
+
# check if this is the last string of an object and therefore we can keep going
|
322
|
+
# make an exception if this is the last char before the closing brace
|
323
|
+
i = self.skip_to_character(character="}", idx=1)
|
324
|
+
if i > 1:
|
325
|
+
# Ok it's not right after the comma
|
326
|
+
# Let's ignore
|
327
|
+
rstring_delimiter_missing = False
|
322
328
|
if rstring_delimiter_missing:
|
323
329
|
self.log(
|
324
330
|
"While parsing a string missing the left delimiter in object value context, we found a , or } and we couldn't determine that a right delimiter was present. Stopping here",
|
@@ -414,11 +420,6 @@ class JSONParser:
|
|
414
420
|
):
|
415
421
|
i += 1
|
416
422
|
i = self.skip_to_character(character=rstring_delimiter, idx=i)
|
417
|
-
# If the rstring_delimeter is escaped then it's not what we are looking for
|
418
|
-
while self.get_char_at(i - 1) == "\\":
|
419
|
-
i = self.skip_to_character(
|
420
|
-
character=rstring_delimiter, idx=i + 1
|
421
|
-
)
|
422
423
|
next_c = self.get_char_at(i)
|
423
424
|
# Ok now I found a delimiter, let's skip whitespaces and see if next we find a }
|
424
425
|
i += 1
|
@@ -432,7 +433,9 @@ class JSONParser:
|
|
432
433
|
string_acc += str(char)
|
433
434
|
self.index += 1
|
434
435
|
char = self.get_char_at()
|
435
|
-
elif
|
436
|
+
elif (
|
437
|
+
next_c == rstring_delimiter and self.get_char_at(i - 1) != "\\"
|
438
|
+
):
|
436
439
|
if self.context.current == ContextValues.OBJECT_VALUE:
|
437
440
|
# But this might not be it! This could be just a missing comma
|
438
441
|
# We found a delimiter and we need to check if this is a key
|
@@ -441,19 +444,13 @@ class JSONParser:
|
|
441
444
|
i = self.skip_to_character(
|
442
445
|
character=rstring_delimiter, idx=i
|
443
446
|
)
|
444
|
-
# If the rstring_delimeter is escaped then it's not what we are looking for
|
445
|
-
while self.get_char_at(i - 1) == "\\":
|
446
|
-
i = self.skip_to_character(
|
447
|
-
character=rstring_delimiter, idx=i + 1
|
448
|
-
)
|
449
447
|
i += 1
|
450
448
|
next_c = self.get_char_at(i)
|
451
449
|
while next_c and next_c != ":":
|
452
|
-
if next_c
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
]:
|
450
|
+
if next_c == "," or (
|
451
|
+
next_c == rstring_delimiter
|
452
|
+
and self.get_char_at(i - 1) != "\\"
|
453
|
+
):
|
457
454
|
break
|
458
455
|
i += 1
|
459
456
|
next_c = self.get_char_at(i)
|
@@ -582,6 +579,9 @@ class JSONParser:
|
|
582
579
|
char = self.json_str[self.index + idx]
|
583
580
|
except IndexError:
|
584
581
|
return idx
|
582
|
+
if self.index + idx > 0 and self.json_str[self.index + idx - 1] == "\\":
|
583
|
+
# Ah this is an escaped character, try again
|
584
|
+
return self.skip_to_character(character=character, idx=idx + 1)
|
585
585
|
return idx
|
586
586
|
|
587
587
|
def _log(self, text: str) -> None:
|
@@ -1,13 +1,13 @@
|
|
1
1
|
json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
|
2
2
|
json_repair/__main__.py,sha256=EsJb-y89uZEvGQQg1GdIDWzfDwfOMvVekKEtdguQXCM,67
|
3
3
|
json_repair/json_context.py,sha256=DdJu3DJR-ANvr8KrWfJqdtOE3uI6_B0VQidKvE3PjJA,1080
|
4
|
-
json_repair/json_parser.py,sha256=
|
4
|
+
json_repair/json_parser.py,sha256=6d8R2m29meyFz2_gxvF5olYs1VytAQTV-rDqIYzwjnE,26385
|
5
5
|
json_repair/json_repair.py,sha256=GTg3OAXRbAJAHWs8oiQDqUHh4h6qKDVvWPXcrqafzLY,6100
|
6
6
|
json_repair/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
7
7
|
json_repair/string_file_wrapper.py,sha256=EHLhNBWoyUitzT08thytYJiNZh_klEFwfT8zutPSdb4,3905
|
8
|
-
json_repair-0.29.
|
9
|
-
json_repair-0.29.
|
10
|
-
json_repair-0.29.
|
11
|
-
json_repair-0.29.
|
12
|
-
json_repair-0.29.
|
13
|
-
json_repair-0.29.
|
8
|
+
json_repair-0.29.6.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
9
|
+
json_repair-0.29.6.dist-info/METADATA,sha256=Us1Nn8o5yaJHnssGY5t7X1yfii0NRCvlSjBH9TyANnw,10686
|
10
|
+
json_repair-0.29.6.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
11
|
+
json_repair-0.29.6.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
|
12
|
+
json_repair-0.29.6.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
13
|
+
json_repair-0.29.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|