json-repair 0.25.1__tar.gz → 0.25.3__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.25.1/src/json_repair.egg-info → json_repair-0.25.3}/PKG-INFO +6 -1
- {json_repair-0.25.1 → json_repair-0.25.3}/README.md +5 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/pyproject.toml +1 -1
- {json_repair-0.25.1 → json_repair-0.25.3}/src/json_repair/json_repair.py +22 -9
- {json_repair-0.25.1 → json_repair-0.25.3/src/json_repair.egg-info}/PKG-INFO +6 -1
- {json_repair-0.25.1 → json_repair-0.25.3}/tests/test_json_repair.py +2 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/LICENSE +0 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/setup.cfg +0 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/src/json_repair/__init__.py +0 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.25.1 → json_repair-0.25.3}/tests/test_performance.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.25.
|
3
|
+
Version: 0.25.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
|
@@ -35,6 +35,11 @@ Requires-Python: >=3.7
|
|
35
35
|
Description-Content-Type: text/markdown
|
36
36
|
License-File: LICENSE
|
37
37
|
|
38
|
+
[](https://pypi.org/project/json-repair/)
|
39
|
+

|
40
|
+
[](https://pypi.org/project/json-repair/)
|
41
|
+
|
42
|
+
|
38
43
|
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.
|
39
44
|
|
40
45
|
Inspired by https://github.com/josdejong/jsonrepair
|
@@ -1,3 +1,8 @@
|
|
1
|
+
[](https://pypi.org/project/json-repair/)
|
2
|
+

|
3
|
+
[](https://pypi.org/project/json-repair/)
|
4
|
+
|
5
|
+
|
1
6
|
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.
|
2
7
|
|
3
8
|
Inspired by https://github.com/josdejong/jsonrepair
|
@@ -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.25.
|
6
|
+
version = "0.25.3"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -352,6 +352,19 @@ class JSONParser:
|
|
352
352
|
)
|
353
353
|
doubled_quotes = True
|
354
354
|
self.index += 1
|
355
|
+
else:
|
356
|
+
# Ok this is not a doubled quote, check if this is an empty string or not
|
357
|
+
i = 1
|
358
|
+
next_c = self.get_char_at(i)
|
359
|
+
while next_c and next_c.isspace():
|
360
|
+
i += 1
|
361
|
+
next_c = self.get_char_at(i)
|
362
|
+
if next_c not in [",", "]", "}"]:
|
363
|
+
self.log(
|
364
|
+
"While parsing a string, we found a doubled quote but it was a mistake, removing one quote",
|
365
|
+
"info",
|
366
|
+
)
|
367
|
+
self.index += 1
|
355
368
|
|
356
369
|
# Initialize our return value
|
357
370
|
string_acc = ""
|
@@ -513,15 +526,15 @@ class JSONParser:
|
|
513
526
|
break
|
514
527
|
i += 1
|
515
528
|
next_c = self.get_char_at(i)
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
529
|
+
# Only if we fail to find a ':' then we know this is misplaced quote
|
530
|
+
if next_c != ":":
|
531
|
+
self.log(
|
532
|
+
"While parsing a string, we a misplaced quote that would have closed the string but has a different meaning here, ignoring it",
|
533
|
+
"info",
|
534
|
+
)
|
535
|
+
string_acc += char
|
536
|
+
self.index += 1
|
537
|
+
char = self.get_char_at()
|
525
538
|
|
526
539
|
if (
|
527
540
|
char
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.25.
|
3
|
+
Version: 0.25.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
|
@@ -35,6 +35,11 @@ Requires-Python: >=3.7
|
|
35
35
|
Description-Content-Type: text/markdown
|
36
36
|
License-File: LICENSE
|
37
37
|
|
38
|
+
[](https://pypi.org/project/json-repair/)
|
39
|
+

|
40
|
+
[](https://pypi.org/project/json-repair/)
|
41
|
+
|
42
|
+
|
38
43
|
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.
|
39
44
|
|
40
45
|
Inspired by https://github.com/josdejong/jsonrepair
|
@@ -95,6 +95,7 @@ def test_missing_and_mixed_quotes():
|
|
95
95
|
== '{"name": "John", "age": 30, "city": "New"}'
|
96
96
|
)
|
97
97
|
assert repair_json('[{"key": "value", COMMENT "notes": "lorem "ipsum", sic."}]') == '[{"key": "value", "notes": "lorem \\"ipsum\\", sic."}]'
|
98
|
+
assert repair_json('{"key": ""value"}') == '{"key": "value"}'
|
98
99
|
|
99
100
|
def test_array_edge_cases():
|
100
101
|
assert repair_json("[1, 2, 3,") == "[1, 2, 3]"
|
@@ -102,6 +103,7 @@ def test_array_edge_cases():
|
|
102
103
|
assert repair_json("[1, 2, ... , 3]") == "[1, 2, 3]"
|
103
104
|
assert repair_json("[1, 2, '...', 3]") == '[1, 2, "...", 3]'
|
104
105
|
assert repair_json("[true, false, null, ...]") == '[true, false, null]'
|
106
|
+
assert repair_json('["a" "b" "c" 1') == '["a", "b", "c", 1]'
|
105
107
|
assert (
|
106
108
|
repair_json('{"employees":["John", "Anna",')
|
107
109
|
== '{"employees": ["John", "Anna"]}'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|