json-repair 0.47.1__tar.gz → 0.47.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.
Files changed (20) hide show
  1. {json_repair-0.47.1/src/json_repair.egg-info → json_repair-0.47.2}/PKG-INFO +1 -1
  2. {json_repair-0.47.1 → json_repair-0.47.2}/pyproject.toml +1 -1
  3. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/json_parser.py +9 -8
  4. {json_repair-0.47.1 → json_repair-0.47.2/src/json_repair.egg-info}/PKG-INFO +1 -1
  5. {json_repair-0.47.1 → json_repair-0.47.2}/tests/test_json_repair.py +1 -0
  6. {json_repair-0.47.1 → json_repair-0.47.2}/LICENSE +0 -0
  7. {json_repair-0.47.1 → json_repair-0.47.2}/README.md +0 -0
  8. {json_repair-0.47.1 → json_repair-0.47.2}/setup.cfg +0 -0
  9. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/__init__.py +0 -0
  10. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/__main__.py +0 -0
  11. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/json_context.py +0 -0
  12. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/json_repair.py +0 -0
  13. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/object_comparer.py +0 -0
  14. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/py.typed +0 -0
  15. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair/string_file_wrapper.py +0 -0
  16. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair.egg-info/SOURCES.txt +0 -0
  17. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair.egg-info/dependency_links.txt +0 -0
  18. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair.egg-info/entry_points.txt +0 -0
  19. {json_repair-0.47.1 → json_repair-0.47.2}/src/json_repair.egg-info/top_level.txt +0 -0
  20. {json_repair-0.47.1 → json_repair-0.47.2}/tests/test_performance.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_repair
3
- Version: 0.47.1
3
+ Version: 0.47.2
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
@@ -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.47.1"
6
+ version = "0.47.2"
7
7
  license = {file = "LICENSE"}
8
8
  authors = [
9
9
  { name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
@@ -97,13 +97,6 @@ class JSONParser:
97
97
  elif char == "[":
98
98
  self.index += 1
99
99
  return self.parse_array()
100
- # there can be an edge case in which a key is empty and at the end of an object
101
- # like "key": }. We return an empty string here to close the object properly
102
- elif self.context.current == ContextValues.OBJECT_VALUE and char == "}":
103
- self.log(
104
- "At the end of an object we found a key with missing value, skipping",
105
- )
106
- return ""
107
100
  # <string> starts with a quote
108
101
  elif not self.context.empty and (char in self.STRING_DELIMITERS or char.isalpha()):
109
102
  return self.parse_string()
@@ -202,7 +195,15 @@ class JSONParser:
202
195
  self.context.reset()
203
196
  self.context.set(ContextValues.OBJECT_VALUE)
204
197
  # The value can be any valid json
205
- value = self.parse_json()
198
+ self.skip_whitespaces_at()
199
+ # Corner case, a lone comma
200
+ value: JSONReturnType = ""
201
+ if (self.get_char_at() or "") in [",", "}"]:
202
+ self.log(
203
+ "While parsing an object value we found a stray , ignoring it",
204
+ )
205
+ else:
206
+ value = self.parse_json()
206
207
 
207
208
  # Reset context since our job is done
208
209
  self.context.reset()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_repair
3
- Version: 0.47.1
3
+ Version: 0.47.2
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
@@ -242,6 +242,7 @@ def test_object_edge_cases():
242
242
  == '{"key": ["arrayvalue"], "key3": "value3", "arrayvalue1": ""}'
243
243
  )
244
244
  assert repair_json('{"key": "{\\\\"key\\\\\\":\\"value\\\\\\"}"}') == '{"key": "{\\"key\\":\\"value\\"}"}'
245
+ assert repair_json('{"key": , "key2": "value2"}') == '{"key": "", "key2": "value2"}'
245
246
 
246
247
 
247
248
  def test_number_edge_cases():
File without changes
File without changes
File without changes