json-repair 0.16.0__tar.gz → 0.16.1__tar.gz
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-0.16.0/src/json_repair.egg-info → json_repair-0.16.1}/PKG-INFO +1 -1
- {json_repair-0.16.0 → json_repair-0.16.1}/pyproject.toml +1 -1
- {json_repair-0.16.0 → json_repair-0.16.1}/src/json_repair/json_repair.py +24 -7
- {json_repair-0.16.0 → json_repair-0.16.1/src/json_repair.egg-info}/PKG-INFO +1 -1
- {json_repair-0.16.0 → json_repair-0.16.1}/tests/test_json_repair.py +1 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/LICENSE +0 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/README.md +0 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/setup.cfg +0 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/src/json_repair/__init__.py +0 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.16.0 → json_repair-0.16.1}/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.16.
|
6
|
+
version = "0.16.1"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -302,7 +302,8 @@ class JSONParser:
|
|
302
302
|
while next_c and next_c != rstring_delimiter:
|
303
303
|
# If we are in an object context, let's check for the right delimiters
|
304
304
|
if (
|
305
|
-
|
305
|
+
next_c == lstring_delimiter
|
306
|
+
or ("object_key" in self.context and next_c == ":")
|
306
307
|
or ("object_value" in self.context and next_c in ["}", ","])
|
307
308
|
or ("array" in self.context and next_c in ["]", ","])
|
308
309
|
):
|
@@ -310,12 +311,28 @@ class JSONParser:
|
|
310
311
|
i += 1
|
311
312
|
next_c = self.get_char_at(i)
|
312
313
|
if next_c == rstring_delimiter:
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
)
|
317
|
-
|
318
|
-
|
314
|
+
# But this might not be it! This could be just a missing comma
|
315
|
+
# We need to check if we find a rstring_delimiter and a colon after
|
316
|
+
i += 1
|
317
|
+
next_c = self.get_char_at(i)
|
318
|
+
while next_c and next_c != rstring_delimiter:
|
319
|
+
i += 1
|
320
|
+
next_c = self.get_char_at(i)
|
321
|
+
i += 1
|
322
|
+
next_c = self.get_char_at(i)
|
323
|
+
while next_c and next_c != ":":
|
324
|
+
if next_c in [lstring_delimiter, rstring_delimiter, ","]:
|
325
|
+
break
|
326
|
+
i += 1
|
327
|
+
next_c = self.get_char_at(i)
|
328
|
+
# Only if we fail to find a ':' then we know this is misplaced quote
|
329
|
+
if next_c != ":":
|
330
|
+
self.log(
|
331
|
+
"While parsing a string, we a misplaced quote that would have closed the string but has a different meaning here, ignoring it",
|
332
|
+
"info",
|
333
|
+
)
|
334
|
+
self.index += 1
|
335
|
+
char = self.get_char_at()
|
319
336
|
|
320
337
|
if (
|
321
338
|
char
|
@@ -115,6 +115,7 @@ def test_repair_json():
|
|
115
115
|
assert repair_json('{"key": .25}') == '{"key": 0.25}'
|
116
116
|
assert repair_json("""{ "a": "", "b": [ { "c": 1} ] \n}```""") == '{"a": "", "b": [{"c": 1}]}'
|
117
117
|
assert repair_json("Based on the information extracted, here is the filled JSON output: ```json { 'a': 'b' } ```") == '{"a": "b"}'
|
118
|
+
assert repair_json('''{"number": 1,"reason": "According...""ans": "YES"}''') == '{"number": 1, "reason": "According...", "ans": "YES"}'
|
118
119
|
|
119
120
|
|
120
121
|
def test_repair_json_with_objects():
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|