json-repair 0.45.1__tar.gz → 0.46.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.45.1/src/json_repair.egg-info → json_repair-0.46.0}/PKG-INFO +1 -1
- {json_repair-0.45.1 → json_repair-0.46.0}/pyproject.toml +1 -1
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/json_parser.py +14 -1
- {json_repair-0.45.1 → json_repair-0.46.0/src/json_repair.egg-info}/PKG-INFO +1 -1
- {json_repair-0.45.1 → json_repair-0.46.0}/tests/test_json_repair.py +1 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/LICENSE +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/README.md +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/setup.cfg +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/__init__.py +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/__main__.py +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/json_context.py +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/json_repair.py +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/object_comparer.py +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/py.typed +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair/string_file_wrapper.py +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair.egg-info/entry_points.txt +0 -0
- {json_repair-0.45.1 → json_repair-0.46.0}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.45.1 → json_repair-0.46.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.46.0"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -231,7 +231,20 @@ class JSONParser:
|
|
231
231
|
char = self.get_char_at()
|
232
232
|
while char and char not in ["]", "}"]:
|
233
233
|
self.skip_whitespaces_at()
|
234
|
-
value =
|
234
|
+
value: JSONReturnType = ""
|
235
|
+
if char in self.STRING_DELIMITERS:
|
236
|
+
# Sometimes it can happen that LLMs forget to start an object and then you think it's a string in an array
|
237
|
+
# So we are going to check if this string is followed by a : or not
|
238
|
+
# And either parse the string or parse the object
|
239
|
+
i = 1
|
240
|
+
i = self.skip_to_character(char, i)
|
241
|
+
i = self.skip_whitespaces_at(idx=i + 1, move_main_index=False)
|
242
|
+
if self.get_char_at(i) == ":":
|
243
|
+
value = self.parse_object()
|
244
|
+
else:
|
245
|
+
value = self.parse_string()
|
246
|
+
else:
|
247
|
+
value = self.parse_json()
|
235
248
|
|
236
249
|
# It is possible that parse_json() returns nothing valid, so we increase by 1
|
237
250
|
if value == "":
|
@@ -193,6 +193,7 @@ def test_array_edge_cases():
|
|
193
193
|
== '{"key": ["lorem \\"ipsum\\" dolor \\"sit\\" amet, \\"consectetur\\" ", "lorem \\"ipsum\\" dolor", "lorem"]}'
|
194
194
|
)
|
195
195
|
assert repair_json('{"k"e"y": "value"}') == '{"k\\"e\\"y": "value"}'
|
196
|
+
assert repair_json('["key":"value"}]') == '[{"key": "value"}]'
|
196
197
|
|
197
198
|
|
198
199
|
def test_escaping():
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|