json-repair 0.5.1__tar.gz → 0.6.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.5.1/src/json_repair.egg-info → json_repair-0.6.0}/PKG-INFO +1 -1
- {json_repair-0.5.1 → json_repair-0.6.0}/pyproject.toml +1 -1
- {json_repair-0.5.1 → json_repair-0.6.0}/src/json_repair/json_repair.py +12 -0
- {json_repair-0.5.1 → json_repair-0.6.0/src/json_repair.egg-info}/PKG-INFO +1 -1
- {json_repair-0.5.1 → json_repair-0.6.0}/tests/test_json_repair.py +6 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/LICENSE +0 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/README.md +0 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/setup.cfg +0 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/src/json_repair/__init__.py +0 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.5.1 → json_repair-0.6.0}/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.
|
6
|
+
version = "0.6.0"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -202,6 +202,7 @@ class JSONParser:
|
|
202
202
|
# * It iterated over the entire sequence
|
203
203
|
# * If we are fixing missing quotes in an object, when it finds the special terminators
|
204
204
|
char = self.get_char_at()
|
205
|
+
fix_broken_markdown_link = False
|
205
206
|
while char and char != string_terminator:
|
206
207
|
if fixed_quotes:
|
207
208
|
if self.context == "object_key" and (char == ":" or char.isspace()):
|
@@ -210,6 +211,17 @@ class JSONParser:
|
|
210
211
|
break
|
211
212
|
self.index += 1
|
212
213
|
char = self.get_char_at()
|
214
|
+
# ChatGPT sometimes forget to quote links in markdown like: { "content": "[LINK]("https://google.com")" }
|
215
|
+
if char == string_terminator and (
|
216
|
+
fix_broken_markdown_link
|
217
|
+
or (
|
218
|
+
self.index - 2 > 0
|
219
|
+
and self.json_str[self.index - 2 : self.index] == "]("
|
220
|
+
)
|
221
|
+
):
|
222
|
+
fix_broken_markdown_link = not fix_broken_markdown_link
|
223
|
+
self.index += 1
|
224
|
+
char = self.get_char_at()
|
213
225
|
|
214
226
|
if char and fixed_quotes and self.context == "object_key" and char.isspace():
|
215
227
|
self.skip_whitespaces_at()
|
@@ -88,6 +88,9 @@ def test_repair_json():
|
|
88
88
|
repair_json('{"": true, "key2": "value2"}') == '{"empty_placeholder": true, "key2": "value_2"}'
|
89
89
|
}
|
90
90
|
|
91
|
+
#Test markdown stupidities from ChatGPT
|
92
|
+
assert repair_json('{ "content": "[LINK]("https://google.com")" }') == '{"content": "[LINK](\\"https://google.com\\")"}'
|
93
|
+
|
91
94
|
|
92
95
|
|
93
96
|
|
@@ -145,6 +148,9 @@ def test_repair_json_with_objects():
|
|
145
148
|
#Test with garbage comments
|
146
149
|
assert repair_json('{"value_1": true, SHOULD_NOT_EXIST "value_2": "data" AAAA }', True) == {'value_1': True, 'value_2': 'data'}
|
147
150
|
|
151
|
+
#Test markdown stupidities from ChatGPT
|
152
|
+
assert repair_json('{ "content": "[LINK]("https://google.com")" }', True) == { "content": "[LINK](\"https://google.com\")"}
|
153
|
+
|
148
154
|
|
149
155
|
def test_repair_json_corner_cases_generate_by_gpt():
|
150
156
|
# Test with nested JSON
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|