json-repair 0.15.3__tar.gz → 0.15.5__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.15.3/src/json_repair.egg-info → json_repair-0.15.5}/PKG-INFO +1 -1
- {json_repair-0.15.3 → json_repair-0.15.5}/pyproject.toml +1 -1
- {json_repair-0.15.3 → json_repair-0.15.5}/src/json_repair/json_repair.py +14 -4
- {json_repair-0.15.3 → json_repair-0.15.5/src/json_repair.egg-info}/PKG-INFO +1 -1
- {json_repair-0.15.3 → json_repair-0.15.5}/tests/test_json_repair.py +2 -2
- {json_repair-0.15.3 → json_repair-0.15.5}/LICENSE +0 -0
- {json_repair-0.15.3 → json_repair-0.15.5}/README.md +0 -0
- {json_repair-0.15.3 → json_repair-0.15.5}/setup.cfg +0 -0
- {json_repair-0.15.3 → json_repair-0.15.5}/src/json_repair/__init__.py +0 -0
- {json_repair-0.15.3 → json_repair-0.15.5}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.15.3 → json_repair-0.15.5}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.15.3 → json_repair-0.15.5}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.15.3 → json_repair-0.15.5}/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.15.
|
6
|
+
version = "0.15.5"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -226,10 +226,20 @@ class JSONParser:
|
|
226
226
|
lstring_delimiter = rstring_delimiter = string_quotes
|
227
227
|
# There is sometimes a weird case of doubled quotes, we manage this also later in the while loop
|
228
228
|
if self.get_char_at(1) == lstring_delimiter:
|
229
|
-
|
230
|
-
|
231
|
-
)
|
232
|
-
|
229
|
+
# This is a valid exception only if it's closed by a double delimiter again
|
230
|
+
i = 2
|
231
|
+
next_c = self.get_char_at(i)
|
232
|
+
while next_c and next_c != rstring_delimiter:
|
233
|
+
i += 1
|
234
|
+
next_c = self.get_char_at(i)
|
235
|
+
# Now check that the next character is also a delimiter to ensure that we have "".....""
|
236
|
+
# In that case we ignore this rstring delimiter
|
237
|
+
if next_c and (self.get_char_at(i + 1) or "") == rstring_delimiter:
|
238
|
+
self.log(
|
239
|
+
"While parsing a string, we found a valid starting doubled quote, ignoring it",
|
240
|
+
"info",
|
241
|
+
)
|
242
|
+
self.index += 1
|
233
243
|
char = self.get_char_at()
|
234
244
|
if char != lstring_delimiter:
|
235
245
|
self.log(
|
@@ -107,11 +107,11 @@ def test_repair_json():
|
|
107
107
|
assert repair_json('{"key\_1\n": "value"}') == '{"key_1": "value"}'
|
108
108
|
assert repair_json('{"key\t\_": "value"}') == '{"key\\t_": "value"}'
|
109
109
|
assert repair_json('{""answer"":[{""traits"":''Female aged 60+'',""answer1"":""5""}]}') == '{"answer": [{"traits": "Female aged 60+", "answer1": "5"}]}'
|
110
|
-
assert repair_json('{""
|
111
|
-
assert repair_json('{"key":"",}') == '{"key": ",}"}'
|
110
|
+
assert repair_json('{"key":""') == '{"key": ""}'
|
112
111
|
assert repair_json('{ "words": abcdef", "numbers": 12345", "words2": ghijkl" }') == '{"words": "abcdef", "numbers": 12345, "words2": "ghijkl"}'
|
113
112
|
assert repair_json('{"key": 1/3}') == '{"key": "1/3"}'
|
114
113
|
assert repair_json('{"key": .25}') == '{"key": 0.25}'
|
114
|
+
assert repair_json("""{ "a": "", "b": [ { "c": 1} ] \n}```""") == '{"a": "", "b": [{"c": 1}]}'
|
115
115
|
|
116
116
|
|
117
117
|
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
|