json-repair 0.11.0__tar.gz → 0.12.0__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.11.0/src/json_repair.egg-info → json_repair-0.12.0}/PKG-INFO +2 -2
- {json_repair-0.11.0 → json_repair-0.12.0}/README.md +1 -1
- {json_repair-0.11.0 → json_repair-0.12.0}/pyproject.toml +1 -1
- {json_repair-0.11.0 → json_repair-0.12.0}/src/json_repair/json_repair.py +7 -0
- {json_repair-0.11.0 → json_repair-0.12.0/src/json_repair.egg-info}/PKG-INFO +2 -2
- {json_repair-0.11.0 → json_repair-0.12.0}/tests/test_json_repair.py +3 -0
- {json_repair-0.11.0 → json_repair-0.12.0}/LICENSE +0 -0
- {json_repair-0.11.0 → json_repair-0.12.0}/setup.cfg +0 -0
- {json_repair-0.11.0 → json_repair-0.12.0}/src/json_repair/__init__.py +0 -0
- {json_repair-0.11.0 → json_repair-0.12.0}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.11.0 → json_repair-0.12.0}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.11.0 → json_repair-0.12.0}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.11.0 → json_repair-0.12.0}/tests/test_performance.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.0
|
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,7 +35,7 @@ Requires-Python: >=3.7
|
|
35
35
|
Description-Content-Type: text/markdown
|
36
36
|
License-File: LICENSE
|
37
37
|
|
38
|
-
This simple package can be used to
|
38
|
+
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
39
|
|
40
40
|
Inspired by https://github.com/josdejong/jsonrepair
|
41
41
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
This simple package can be used to
|
1
|
+
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
2
|
|
3
3
|
Inspired by https://github.com/josdejong/jsonrepair
|
4
4
|
|
@@ -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.
|
6
|
+
version = "0.12.0"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -177,12 +177,16 @@ class JSONParser:
|
|
177
177
|
|
178
178
|
# Flag to manage corner cases related to missing starting quote
|
179
179
|
fixed_quotes = False
|
180
|
+
double_double_quotes = False
|
180
181
|
lstring_delimiter = rstring_delimiter = '"'
|
181
182
|
if isinstance(string_quotes, list):
|
182
183
|
lstring_delimiter = string_quotes[0]
|
183
184
|
rstring_delimiter = string_quotes[1]
|
184
185
|
elif isinstance(string_quotes, str):
|
185
186
|
lstring_delimiter = rstring_delimiter = string_quotes
|
187
|
+
if lstring_delimiter == '"' and self.get_char_at(1) == '"':
|
188
|
+
double_double_quotes = True
|
189
|
+
self.index += 1
|
186
190
|
char = self.get_char_at()
|
187
191
|
if char != lstring_delimiter:
|
188
192
|
self.insert_char_at(lstring_delimiter)
|
@@ -216,6 +220,7 @@ class JSONParser:
|
|
216
220
|
char = self.get_char_at()
|
217
221
|
else:
|
218
222
|
self.remove_char_at(-1)
|
223
|
+
self.index -= 1
|
219
224
|
# ChatGPT sometimes forget to quote links in markdown like: { "content": "[LINK]("https://google.com")" }
|
220
225
|
if (
|
221
226
|
char == rstring_delimiter
|
@@ -241,6 +246,8 @@ class JSONParser:
|
|
241
246
|
if char != rstring_delimiter:
|
242
247
|
self.insert_char_at(rstring_delimiter)
|
243
248
|
else:
|
249
|
+
if double_double_quotes:
|
250
|
+
self.index += 1
|
244
251
|
self.index += 1
|
245
252
|
|
246
253
|
return self.json_str[start:end]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.12.0
|
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,7 +35,7 @@ Requires-Python: >=3.7
|
|
35
35
|
Description-Content-Type: text/markdown
|
36
36
|
License-File: LICENSE
|
37
37
|
|
38
|
-
This simple package can be used to
|
38
|
+
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
39
|
|
40
40
|
Inspired by https://github.com/josdejong/jsonrepair
|
41
41
|
|
@@ -105,6 +105,9 @@ def test_repair_json():
|
|
105
105
|
assert repair_json('````{ "key": "value" }```') == '{"key": "value"}'
|
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
|
+
assert repair_json('{"key\t\_": "value"}') == '{"key\\t_": "value"}'
|
109
|
+
assert repair_json('{""answer"":[{""traits"":""Female aged 60+"",""answer1"":""5""}]}') == '{"answer": [{"traits": "Female aged 60+", "answer1": "5"}]}'
|
110
|
+
assert repair_json('{"key":"",}') == '{"key": ",}"}'
|
108
111
|
|
109
112
|
|
110
113
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|