json-repair 0.52.1__tar.gz → 0.52.3__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.
Files changed (35) hide show
  1. {json_repair-0.52.1/src/json_repair.egg-info → json_repair-0.52.3}/PKG-INFO +1 -1
  2. {json_repair-0.52.1 → json_repair-0.52.3}/pyproject.toml +1 -1
  3. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/json_parser.py +1 -0
  4. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/parse_string.py +11 -0
  5. {json_repair-0.52.1 → json_repair-0.52.3/src/json_repair.egg-info}/PKG-INFO +1 -1
  6. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_parse_object.py +1 -0
  7. {json_repair-0.52.1 → json_repair-0.52.3}/LICENSE +0 -0
  8. {json_repair-0.52.1 → json_repair-0.52.3}/README.md +0 -0
  9. {json_repair-0.52.1 → json_repair-0.52.3}/setup.cfg +0 -0
  10. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/__init__.py +0 -0
  11. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/__main__.py +0 -0
  12. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/constants.py +0 -0
  13. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/json_context.py +0 -0
  14. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/json_repair.py +0 -0
  15. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/object_comparer.py +0 -0
  16. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/parse_array.py +0 -0
  17. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/parse_boolean_or_null.py +0 -0
  18. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/parse_comment.py +0 -0
  19. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/parse_number.py +0 -0
  20. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/parse_object.py +0 -0
  21. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/py.typed +0 -0
  22. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair/string_file_wrapper.py +0 -0
  23. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair.egg-info/SOURCES.txt +0 -0
  24. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair.egg-info/dependency_links.txt +0 -0
  25. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair.egg-info/entry_points.txt +0 -0
  26. {json_repair-0.52.1 → json_repair-0.52.3}/src/json_repair.egg-info/top_level.txt +0 -0
  27. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_json_repair.py +0 -0
  28. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_parse_array.py +0 -0
  29. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_parse_boolean_or_null.py +0 -0
  30. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_parse_comment.py +0 -0
  31. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_parse_number.py +0 -0
  32. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_parse_string.py +0 -0
  33. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_performance.py +0 -0
  34. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_repair_json_cli.py +0 -0
  35. {json_repair-0.52.1 → json_repair-0.52.3}/tests/test_repair_json_from_file.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_repair
3
- Version: 0.52.1
3
+ Version: 0.52.3
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-Expression: MIT
@@ -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.52.1"
6
+ version = "0.52.3"
7
7
  license = "MIT"
8
8
  license-files = ["LICENSE"]
9
9
  authors = [
@@ -81,6 +81,7 @@ class JSONParser:
81
81
  )
82
82
  json = [json]
83
83
  while self.index < len(self.json_str):
84
+ self.context.reset()
84
85
  j = self.parse_json()
85
86
  if j != "":
86
87
  if ObjectComparer.is_same_object(json[-1], j):
@@ -206,6 +206,17 @@ def parse_string(self: "JSONParser") -> JSONReturnType:
206
206
  # Check if the object is really over, to avoid doubling the closing brace
207
207
  i = self.skip_whitespaces_at(idx=1, move_main_index=False)
208
208
  next_c = self.get_char_at(i)
209
+ if next_c and next_c == "`":
210
+ # This could be a special case in which the LLM added code fences after the object
211
+ # So we need to check if there are another two ` after this one`
212
+ next_c = self.get_char_at(i + 1)
213
+ if next_c and next_c == "`":
214
+ next_c = self.get_char_at(i + 2)
215
+ if next_c and next_c == "`":
216
+ self.log(
217
+ "While parsing a string in object value context, we found a } that closes the object before code fences, stopping here",
218
+ )
219
+ break
209
220
  if not next_c:
210
221
  self.log(
211
222
  "While parsing a string in object value context, we found a } that closes the object, stopping here",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_repair
3
- Version: 0.52.1
3
+ Version: 0.52.3
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-Expression: MIT
@@ -63,6 +63,7 @@ def test_parse_object_edge_cases():
63
63
  assert repair_json("{text:words{words in brackets}}") == '{"text": "words{words in brackets}"}'
64
64
  assert repair_json("{text:words{words in brackets}m}") == '{"text": "words{words in brackets}m"}'
65
65
  assert repair_json('{"key": "value, value2"```') == '{"key": "value, value2"}'
66
+ assert repair_json('{"key": "value}```') == '{"key": "value"}'
66
67
  assert repair_json("{key:value,key2:value2}") == '{"key": "value", "key2": "value2"}'
67
68
  assert repair_json('{"key:"value"}') == '{"key": "value"}'
68
69
  assert repair_json('{"key:value}') == '{"key": "value"}'
File without changes
File without changes
File without changes