json-repair 0.19.2__py3-none-any.whl → 0.20.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_repair.py +32 -14
- {json_repair-0.19.2.dist-info → json_repair-0.20.0.dist-info}/METADATA +1 -1
- json_repair-0.20.0.dist-info/RECORD +7 -0
- json_repair-0.19.2.dist-info/RECORD +0 -7
- {json_repair-0.19.2.dist-info → json_repair-0.20.0.dist-info}/LICENSE +0 -0
- {json_repair-0.19.2.dist-info → json_repair-0.20.0.dist-info}/WHEEL +0 -0
- {json_repair-0.19.2.dist-info → json_repair-0.20.0.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -335,32 +335,50 @@ class JSONParser:
|
|
335
335
|
# Check if eventually there is a rstring delimiter, otherwise we bail
|
336
336
|
i = 1
|
337
337
|
next_c = self.get_char_at(i)
|
338
|
-
|
338
|
+
check_comma_in_object_value = True
|
339
|
+
while next_c and next_c not in [
|
340
|
+
rstring_delimiter,
|
341
|
+
lstring_delimiter,
|
342
|
+
]:
|
343
|
+
# This is a bit of a weird workaround, essentially in object_value context we don't always break on commas
|
344
|
+
# This is because the routine after will make sure to correct any bad guess and this solves a corner case
|
345
|
+
if next_c.isalpha():
|
346
|
+
check_comma_in_object_value = False
|
339
347
|
# If we are in an object context, let's check for the right delimiters
|
340
348
|
if (
|
341
|
-
next_c
|
342
|
-
or ("
|
343
|
-
or ("object_value" in self.context and next_c in ["}", ","])
|
349
|
+
("object_key" in self.context and next_c in [":", "}"])
|
350
|
+
or ("object_value" in self.context and next_c == "}")
|
344
351
|
or ("array" in self.context and next_c in ["]", ","])
|
352
|
+
or (
|
353
|
+
check_comma_in_object_value
|
354
|
+
and self.get_context() == "object_value"
|
355
|
+
and next_c == ","
|
356
|
+
)
|
345
357
|
):
|
346
358
|
break
|
347
359
|
i += 1
|
348
360
|
next_c = self.get_char_at(i)
|
349
361
|
if next_c == rstring_delimiter:
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
while next_c and next_c != rstring_delimiter:
|
362
|
+
if self.get_context() == "object_value":
|
363
|
+
# But this might not be it! This could be just a missing comma
|
364
|
+
# We found a delimiter and we need to check if this is a key
|
365
|
+
# so find a rstring_delimiter and a colon after
|
355
366
|
i += 1
|
356
367
|
next_c = self.get_char_at(i)
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
if next_c in [lstring_delimiter, rstring_delimiter, ","]:
|
361
|
-
break
|
368
|
+
while next_c and next_c != rstring_delimiter:
|
369
|
+
i += 1
|
370
|
+
next_c = self.get_char_at(i)
|
362
371
|
i += 1
|
363
372
|
next_c = self.get_char_at(i)
|
373
|
+
while next_c and next_c != ":":
|
374
|
+
if next_c in [
|
375
|
+
lstring_delimiter,
|
376
|
+
rstring_delimiter,
|
377
|
+
",",
|
378
|
+
]:
|
379
|
+
break
|
380
|
+
i += 1
|
381
|
+
next_c = self.get_char_at(i)
|
364
382
|
# Only if we fail to find a ':' then we know this is misplaced quote
|
365
383
|
if next_c != ":":
|
366
384
|
self.log(
|
@@ -0,0 +1,7 @@
|
|
1
|
+
json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
|
2
|
+
json_repair/json_repair.py,sha256=zYg4tIwZ4rdVkCQ5XVceNQaOz2MT50O7jHJbJ1EpKhk,25446
|
3
|
+
json_repair-0.20.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
+
json_repair-0.20.0.dist-info/METADATA,sha256=2WrsjORPx37e4CqdkdiARwB-VoP5EyjsZaS0hcVnVBo,7333
|
5
|
+
json_repair-0.20.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
json_repair-0.20.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
+
json_repair-0.20.0.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
|
2
|
-
json_repair/json_repair.py,sha256=qNkCy5by3jFhCAC3pDNKzDECOJr1Crh-P71j6N1CBBg,24405
|
3
|
-
json_repair-0.19.2.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
-
json_repair-0.19.2.dist-info/METADATA,sha256=UdTpknO6GMk16WlPV-YxSFd_QbY25WiNkqj2IE3B_NA,7333
|
5
|
-
json_repair-0.19.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
json_repair-0.19.2.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
-
json_repair-0.19.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|