json-repair 0.12.0__tar.gz → 0.12.2__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.12.0/src/json_repair.egg-info → json_repair-0.12.2}/PKG-INFO +1 -1
- {json_repair-0.12.0 → json_repair-0.12.2}/pyproject.toml +1 -1
- {json_repair-0.12.0 → json_repair-0.12.2}/src/json_repair/json_repair.py +5 -5
- {json_repair-0.12.0 → json_repair-0.12.2/src/json_repair.egg-info}/PKG-INFO +1 -1
- {json_repair-0.12.0 → json_repair-0.12.2}/tests/test_json_repair.py +2 -1
- {json_repair-0.12.0 → json_repair-0.12.2}/LICENSE +0 -0
- {json_repair-0.12.0 → json_repair-0.12.2}/README.md +0 -0
- {json_repair-0.12.0 → json_repair-0.12.2}/setup.cfg +0 -0
- {json_repair-0.12.0 → json_repair-0.12.2}/src/json_repair/__init__.py +0 -0
- {json_repair-0.12.0 → json_repair-0.12.2}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.12.0 → json_repair-0.12.2}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.12.0 → json_repair-0.12.2}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.12.0 → json_repair-0.12.2}/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.12.
|
6
|
+
version = "0.12.2"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -177,15 +177,15 @@ class JSONParser:
|
|
177
177
|
|
178
178
|
# Flag to manage corner cases related to missing starting quote
|
179
179
|
fixed_quotes = False
|
180
|
-
|
180
|
+
double_delimiter = False
|
181
181
|
lstring_delimiter = rstring_delimiter = '"'
|
182
182
|
if isinstance(string_quotes, list):
|
183
183
|
lstring_delimiter = string_quotes[0]
|
184
184
|
rstring_delimiter = string_quotes[1]
|
185
185
|
elif isinstance(string_quotes, str):
|
186
186
|
lstring_delimiter = rstring_delimiter = string_quotes
|
187
|
-
if
|
188
|
-
|
187
|
+
if self.get_char_at(1) == lstring_delimiter:
|
188
|
+
double_delimiter = True
|
189
189
|
self.index += 1
|
190
190
|
char = self.get_char_at()
|
191
191
|
if char != lstring_delimiter:
|
@@ -246,9 +246,9 @@ class JSONParser:
|
|
246
246
|
if char != rstring_delimiter:
|
247
247
|
self.insert_char_at(rstring_delimiter)
|
248
248
|
else:
|
249
|
-
if double_double_quotes:
|
250
|
-
self.index += 1
|
251
249
|
self.index += 1
|
250
|
+
if double_delimiter and self.get_char_at() == rstring_delimiter:
|
251
|
+
self.index += 1
|
252
252
|
|
253
253
|
return self.json_str[start:end]
|
254
254
|
|
@@ -106,7 +106,8 @@ def test_repair_json():
|
|
106
106
|
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=\\\"https://domain.com\\\">Some link</a>"}'
|
107
107
|
assert repair_json('{"key\_1\n": "value"}') == '{"key_1\\n": "value"}'
|
108
108
|
assert repair_json('{"key\t\_": "value"}') == '{"key\\t_": "value"}'
|
109
|
-
assert repair_json('{""answer"":[{""traits"":
|
109
|
+
assert repair_json('{""answer"":[{""traits"":''Female aged 60+'',""answer1"":""5""}]}') == '{"answer": [{"traits": "Female aged 60+", "answer1": "5"}]}'
|
110
|
+
assert repair_json('{""answer":[{""traits":""Female aged 60+",""answer1":""5"}]}') == '{"answer": [{"traits": "Female aged 60+", "answer1": "5"}]}'
|
110
111
|
assert repair_json('{"key":"",}') == '{"key": ",}"}'
|
111
112
|
|
112
113
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|