json-repair 0.29.4__tar.gz → 0.29.6__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {json_repair-0.29.4/src/json_repair.egg-info → json_repair-0.29.6}/PKG-INFO +1 -1
- {json_repair-0.29.4 → json_repair-0.29.6}/pyproject.toml +1 -1
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/json_parser.py +19 -6
- {json_repair-0.29.4 → json_repair-0.29.6/src/json_repair.egg-info}/PKG-INFO +1 -1
- {json_repair-0.29.4 → json_repair-0.29.6}/tests/test_json_repair.py +1 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/LICENSE +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/README.md +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/setup.cfg +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/__init__.py +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/__main__.py +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/json_context.py +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/json_repair.py +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/py.typed +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/string_file_wrapper.py +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/entry_points.txt +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/tests/test_coverage.py +0 -0
- {json_repair-0.29.4 → json_repair-0.29.6}/tests/test_performance.py +0 -0
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
4
4
|
[project]
|
5
5
|
name = "json_repair"
|
6
|
-
version = "0.29.
|
6
|
+
version = "0.29.6"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -316,6 +316,15 @@ class JSONParser:
|
|
316
316
|
next_c = self.get_char_at(i)
|
317
317
|
if next_c and next_c in [",", "}"]:
|
318
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
|
319
328
|
if rstring_delimiter_missing:
|
320
329
|
self.log(
|
321
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",
|
@@ -424,7 +433,9 @@ class JSONParser:
|
|
424
433
|
string_acc += str(char)
|
425
434
|
self.index += 1
|
426
435
|
char = self.get_char_at()
|
427
|
-
elif
|
436
|
+
elif (
|
437
|
+
next_c == rstring_delimiter and self.get_char_at(i - 1) != "\\"
|
438
|
+
):
|
428
439
|
if self.context.current == ContextValues.OBJECT_VALUE:
|
429
440
|
# But this might not be it! This could be just a missing comma
|
430
441
|
# We found a delimiter and we need to check if this is a key
|
@@ -436,11 +447,10 @@ class JSONParser:
|
|
436
447
|
i += 1
|
437
448
|
next_c = self.get_char_at(i)
|
438
449
|
while next_c and next_c != ":":
|
439
|
-
if next_c
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
]:
|
450
|
+
if next_c == "," or (
|
451
|
+
next_c == rstring_delimiter
|
452
|
+
and self.get_char_at(i - 1) != "\\"
|
453
|
+
):
|
444
454
|
break
|
445
455
|
i += 1
|
446
456
|
next_c = self.get_char_at(i)
|
@@ -569,6 +579,9 @@ class JSONParser:
|
|
569
579
|
char = self.json_str[self.index + idx]
|
570
580
|
except IndexError:
|
571
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)
|
572
585
|
return idx
|
573
586
|
|
574
587
|
def _log(self, text: str) -> None:
|
@@ -140,6 +140,7 @@ def test_object_edge_cases():
|
|
140
140
|
assert repair_json('{"key": "Lorem "ipsum" s,"}') == '{"key": "Lorem \\"ipsum\\" s,"}'
|
141
141
|
assert repair_json('{"lorem": ipsum, sic, datum.",}') == '{"lorem": "ipsum, sic, datum."}'
|
142
142
|
assert repair_json('{"lorem": sic tamet. "ipsum": sic tamet, quick brown fox. "sic": ipsum}') == '{"lorem": "sic tamet.", "ipsum": "sic tamet", "sic": "ipsum"}'
|
143
|
+
assert repair_json('{"lorem_ipsum": "sic tamet, quick brown fox. }') == '{"lorem_ipsum": "sic tamet, quick brown fox."}'
|
143
144
|
assert repair_json('{"key":value, " key2":"value2" }') == '{"key": "value", " key2": "value2"}'
|
144
145
|
assert repair_json('{"key":value "key2":"value2" }') == '{"key": "value", "key2": "value2"}'
|
145
146
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|