json-repair 0.19.0__tar.gz → 0.19.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.19.0/src/json_repair.egg-info → json_repair-0.19.1}/PKG-INFO +1 -1
- {json_repair-0.19.0 → json_repair-0.19.1}/pyproject.toml +1 -1
- {json_repair-0.19.0 → json_repair-0.19.1}/src/json_repair/json_repair.py +9 -0
- {json_repair-0.19.0 → json_repair-0.19.1/src/json_repair.egg-info}/PKG-INFO +1 -1
- {json_repair-0.19.0 → json_repair-0.19.1}/tests/test_json_repair.py +2 -2
- {json_repair-0.19.0 → json_repair-0.19.1}/LICENSE +0 -0
- {json_repair-0.19.0 → json_repair-0.19.1}/README.md +0 -0
- {json_repair-0.19.0 → json_repair-0.19.1}/setup.cfg +0 -0
- {json_repair-0.19.0 → json_repair-0.19.1}/src/json_repair/__init__.py +0 -0
- {json_repair-0.19.0 → json_repair-0.19.1}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.19.0 → json_repair-0.19.1}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.19.0 → json_repair-0.19.1}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.19.0 → json_repair-0.19.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.19.
|
6
|
+
version = "0.19.1"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -309,6 +309,15 @@ class JSONParser:
|
|
309
309
|
string_acc += char
|
310
310
|
self.index += 1
|
311
311
|
char = self.get_char_at()
|
312
|
+
if len(string_acc) > 1 and string_acc[-1] == "\\":
|
313
|
+
# This is a special case, if people use real strings this might happen
|
314
|
+
self.log("Found a stray escape sequence, normalizing it", "info")
|
315
|
+
string_acc = string_acc[:-1]
|
316
|
+
if char in [rstring_delimiter, "t", "n", "r", "b", "\\"]:
|
317
|
+
escape_seqs = {"t": "\t", "n": "\n", "r": "\r", "b": "\b"}
|
318
|
+
string_acc += escape_seqs.get(char, char)
|
319
|
+
self.index += 1
|
320
|
+
char = self.get_char_at()
|
312
321
|
# ChatGPT sometimes forget to quote stuff in html tags or markdown, so we do this whole thing here
|
313
322
|
if char == rstring_delimiter:
|
314
323
|
# Special case here, in case of double quotes one after another
|
@@ -59,7 +59,7 @@ def test_repair_json():
|
|
59
59
|
assert repair_json('{"') == '{}'
|
60
60
|
assert repair_json('["') == '[]'
|
61
61
|
assert repair_json("'\"'") == '"\\\""'
|
62
|
-
assert repair_json("{\"key\": 'string\"\n\t\le'") == '{"key": "string\\"\\n\\
|
62
|
+
assert repair_json("{\"key\": 'string\"\n\t\le'") == '{"key": "string\\"\\n\\tle"}'
|
63
63
|
assert repair_json('{foo: [}') == '{"foo": []}'
|
64
64
|
assert repair_json('''{ "a": "{ b": {} }" }''') == '{"a": "{ b"}'
|
65
65
|
assert repair_json('{"key": "value:value"}') == '{"key": "value:value"}'
|
@@ -110,7 +110,7 @@ def test_repair_json():
|
|
110
110
|
{ "key": "value" }
|
111
111
|
```""") == '{"key": "value"}'
|
112
112
|
assert repair_json('````{ "key": "value" }```') == '{"key": "value"}'
|
113
|
-
assert repair_json(r'{"real_content": "Some string: Some other string Some string <a href=\"https://domain.com\">Some link</a>"') == r'{"real_content": "Some string: Some other string Some string <a href
|
113
|
+
assert repair_json(r'{"real_content": "Some string: Some other string \t Some string <a href=\"https://domain.com\">Some link</a>"') == r'{"real_content": "Some string: Some other string \t Some string <a href=\"https://domain.com\">Some link</a>"}'
|
114
114
|
assert repair_json('{"key_1\n": "value"}') == '{"key_1": "value"}'
|
115
115
|
assert repair_json('{"key\t_": "value"}') == '{"key\\t_": "value"}'
|
116
116
|
assert repair_json('{""answer"":[{""traits"":''Female aged 60+'',""answer1"":""5""}]}') == '{"answer": [{"traits": "Female aged 60+", "answer1": "5"}]}'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|