json-repair 0.31.0__py3-none-any.whl → 0.33.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 +32 -2
- {json_repair-0.31.0.dist-info → json_repair-0.33.0.dist-info}/METADATA +1 -1
- {json_repair-0.31.0.dist-info → json_repair-0.33.0.dist-info}/RECORD +7 -7
- {json_repair-0.31.0.dist-info → json_repair-0.33.0.dist-info}/LICENSE +0 -0
- {json_repair-0.31.0.dist-info → json_repair-0.33.0.dist-info}/WHEEL +0 -0
- {json_repair-0.31.0.dist-info → json_repair-0.33.0.dist-info}/entry_points.txt +0 -0
- {json_repair-0.31.0.dist-info → json_repair-0.33.0.dist-info}/top_level.txt +0 -0
json_repair/json_parser.py
CHANGED
@@ -124,6 +124,9 @@ class JSONParser:
|
|
124
124
|
|
125
125
|
self.skip_whitespaces_at()
|
126
126
|
|
127
|
+
# Save this index in case we need find a duplicate key
|
128
|
+
rollback_index = self.index
|
129
|
+
|
127
130
|
# <member> starts with a <string>
|
128
131
|
key = ""
|
129
132
|
while self.get_char_at():
|
@@ -132,7 +135,14 @@ class JSONParser:
|
|
132
135
|
if key != "" or (key == "" and self.get_char_at() == ":"):
|
133
136
|
# If the string is empty but there is a object divider, we are done here
|
134
137
|
break
|
138
|
+
if ContextValues.ARRAY in self.context.context and key in obj:
|
139
|
+
self.log(
|
140
|
+
"While parsing an object we found a duplicate key, closing the object here and rolling back the index",
|
141
|
+
)
|
142
|
+
self.index = rollback_index - 1
|
143
|
+
break
|
135
144
|
|
145
|
+
# Skip filler whitespaces
|
136
146
|
self.skip_whitespaces_at()
|
137
147
|
|
138
148
|
# We reached the end here
|
@@ -498,9 +508,8 @@ class JSONParser:
|
|
498
508
|
# But this might not be it! This could be just a missing comma
|
499
509
|
# We found a delimiter and we need to check if this is a key
|
500
510
|
# so find a rstring_delimiter and a colon after
|
501
|
-
i += 1
|
502
511
|
i = self.skip_to_character(
|
503
|
-
character=rstring_delimiter, idx=i
|
512
|
+
character=rstring_delimiter, idx=i + 1
|
504
513
|
)
|
505
514
|
i += 1
|
506
515
|
next_c = self.get_char_at(i)
|
@@ -521,6 +530,27 @@ class JSONParser:
|
|
521
530
|
string_acc += str(char)
|
522
531
|
self.index += 1
|
523
532
|
char = self.get_char_at()
|
533
|
+
elif self.context.current == ContextValues.ARRAY:
|
534
|
+
# In array context this could be something like "lorem "ipsum" sic"
|
535
|
+
# So let's check if we find a rstring_delimiter forward otherwise end early
|
536
|
+
i = self.skip_to_character(rstring_delimiter, idx=i + 1)
|
537
|
+
next_c = self.get_char_at(i)
|
538
|
+
if next_c and next_c == rstring_delimiter:
|
539
|
+
# Ok now if I find a comma or a closing ], that can be have also an optional rstring_delimiter before them
|
540
|
+
# We can consider this a misplaced quote
|
541
|
+
i += 1
|
542
|
+
i = self.skip_whitespaces_at(
|
543
|
+
idx=i, move_main_index=False
|
544
|
+
)
|
545
|
+
next_c = self.get_char_at(i)
|
546
|
+
if next_c and next_c in [",", "]"]:
|
547
|
+
self.log(
|
548
|
+
"While parsing a string, we a misplaced quote that would have closed the string but has a different meaning here, ignoring it",
|
549
|
+
)
|
550
|
+
unmatched_delimiter = not unmatched_delimiter
|
551
|
+
string_acc += str(char)
|
552
|
+
self.index += 1
|
553
|
+
char = self.get_char_at()
|
524
554
|
|
525
555
|
if (
|
526
556
|
char
|
@@ -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=qLMNN6xJm-8CM4446WizbENCBnFKzEoSM4VLZXTGXaQ,31831
|
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.
|
9
|
-
json_repair-0.
|
10
|
-
json_repair-0.
|
11
|
-
json_repair-0.
|
12
|
-
json_repair-0.
|
13
|
-
json_repair-0.
|
8
|
+
json_repair-0.33.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
9
|
+
json_repair-0.33.0.dist-info/METADATA,sha256=-cTTyNlIlv3xouXyqxRuHDhSXT-2_QuB5AdeKpDbxs4,11794
|
10
|
+
json_repair-0.33.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
11
|
+
json_repair-0.33.0.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
|
12
|
+
json_repair-0.33.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
13
|
+
json_repair-0.33.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|