json-repair 0.30.1__py3-none-any.whl → 0.30.3__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- json_repair/json_parser.py +36 -20
- {json_repair-0.30.1.dist-info → json_repair-0.30.3.dist-info}/METADATA +1 -3
- {json_repair-0.30.1.dist-info → json_repair-0.30.3.dist-info}/RECORD +7 -7
- {json_repair-0.30.1.dist-info → json_repair-0.30.3.dist-info}/WHEEL +1 -1
- {json_repair-0.30.1.dist-info → json_repair-0.30.3.dist-info}/LICENSE +0 -0
- {json_repair-0.30.1.dist-info → json_repair-0.30.3.dist-info}/entry_points.txt +0 -0
- {json_repair-0.30.1.dist-info → json_repair-0.30.3.dist-info}/top_level.txt +0 -0
json_repair/json_parser.py
CHANGED
@@ -328,31 +328,47 @@ class JSONParser:
|
|
328
328
|
if not next_c:
|
329
329
|
rstring_delimiter_missing = False
|
330
330
|
else:
|
331
|
-
#
|
332
|
-
|
333
|
-
#
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
#
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
331
|
+
# There could be a case in which even the next key:value is missing delimeters
|
332
|
+
# because it might be a systemic issue with the output
|
333
|
+
# So let's check if we can find a : in the string instead
|
334
|
+
i = self.skip_to_character(character=":", idx=1)
|
335
|
+
next_c = self.get_char_at(i)
|
336
|
+
if next_c:
|
337
|
+
# OK then this is a systemic issue with the output
|
338
|
+
break
|
339
|
+
else:
|
340
|
+
# skip any whitespace first
|
341
|
+
i = self.skip_whitespaces_at(idx=1, move_main_index=False)
|
342
|
+
# We couldn't find any rstring_delimeter before the end of the string
|
343
|
+
# check if this is the last string of an object and therefore we can keep going
|
344
|
+
# make an exception if this is the last char before the closing brace
|
345
|
+
j = self.skip_to_character(character="}", idx=i)
|
346
|
+
if j - i > 1:
|
347
|
+
# Ok it's not right after the comma
|
348
|
+
# Let's ignore
|
349
|
+
rstring_delimiter_missing = False
|
350
|
+
# Check that j was not out of bound
|
351
|
+
elif self.get_char_at(j):
|
352
|
+
# Check for an unmatched opening brace in string_acc
|
353
|
+
for c in reversed(string_acc):
|
354
|
+
if c == "{":
|
355
|
+
# Ok then this is part of the string
|
356
|
+
rstring_delimiter_missing = False
|
357
|
+
break
|
358
|
+
elif c == "}":
|
359
|
+
break
|
351
360
|
if rstring_delimiter_missing:
|
352
361
|
self.log(
|
353
362
|
"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",
|
354
363
|
)
|
355
364
|
break
|
365
|
+
if char == "]" and ContextValues.ARRAY in self.context.context:
|
366
|
+
# We found the end of an array and we are in array context
|
367
|
+
# So let's check if we find a rstring_delimiter forward otherwise end early
|
368
|
+
i = self.skip_to_character(rstring_delimiter)
|
369
|
+
if not self.get_char_at(i):
|
370
|
+
# No delimiter found
|
371
|
+
break
|
356
372
|
string_acc += char
|
357
373
|
self.index += 1
|
358
374
|
char = self.get_char_at()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.30.
|
3
|
+
Version: 0.30.3
|
4
4
|
Summary: A package to repair broken json strings
|
5
5
|
Author-email: Stefano Baccianella <4247706+mangiucugna@users.noreply.github.com>
|
6
6
|
License: MIT License
|
@@ -45,8 +45,6 @@ License-File: LICENSE
|
|
45
45
|
|
46
46
|
This simple package can be used to fix an invalid json string. To know all cases in which this package will work, check out the unit test.
|
47
47
|
|
48
|
-
Inspired by https://github.com/josdejong/jsonrepair
|
49
|
-
|
50
48
|

|
51
49
|
|
52
50
|
---
|
@@ -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=Vdz3gUrweG4wh0Vh-xpv6HpFtoUH1Hc6Nu0b5smdcM0,29114
|
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=EHLhNBWoyUitzT08thytYJiNZh_klEFwfT8zutPSdb4,3905
|
8
|
-
json_repair-0.30.
|
9
|
-
json_repair-0.30.
|
10
|
-
json_repair-0.30.
|
11
|
-
json_repair-0.30.
|
12
|
-
json_repair-0.30.
|
13
|
-
json_repair-0.30.
|
8
|
+
json_repair-0.30.3.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
9
|
+
json_repair-0.30.3.dist-info/METADATA,sha256=kUHN-HfYfhT0qCuh8KAKdhKI-vn4_tpSIsRTcN4xl8o,11794
|
10
|
+
json_repair-0.30.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
11
|
+
json_repair-0.30.3.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
|
12
|
+
json_repair-0.30.3.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
13
|
+
json_repair-0.30.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|