json-repair 0.29.4__tar.gz → 0.29.6__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.29.4/src/json_repair.egg-info → json_repair-0.29.6}/PKG-INFO +1 -1
  2. {json_repair-0.29.4 → json_repair-0.29.6}/pyproject.toml +1 -1
  3. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/json_parser.py +19 -6
  4. {json_repair-0.29.4 → json_repair-0.29.6/src/json_repair.egg-info}/PKG-INFO +1 -1
  5. {json_repair-0.29.4 → json_repair-0.29.6}/tests/test_json_repair.py +1 -0
  6. {json_repair-0.29.4 → json_repair-0.29.6}/LICENSE +0 -0
  7. {json_repair-0.29.4 → json_repair-0.29.6}/README.md +0 -0
  8. {json_repair-0.29.4 → json_repair-0.29.6}/setup.cfg +0 -0
  9. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/__init__.py +0 -0
  10. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/__main__.py +0 -0
  11. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/json_context.py +0 -0
  12. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/json_repair.py +0 -0
  13. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/py.typed +0 -0
  14. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair/string_file_wrapper.py +0 -0
  15. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/SOURCES.txt +0 -0
  16. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/dependency_links.txt +0 -0
  17. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/entry_points.txt +0 -0
  18. {json_repair-0.29.4 → json_repair-0.29.6}/src/json_repair.egg-info/top_level.txt +0 -0
  19. {json_repair-0.29.4 → json_repair-0.29.6}/tests/test_coverage.py +0 -0
  20. {json_repair-0.29.4 → json_repair-0.29.6}/tests/test_performance.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.29.4
3
+ Version: 0.29.6
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.29.4"
6
+ version = "0.29.6"
7
7
  license = {file = "LICENSE"}
8
8
  authors = [
9
9
  { name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
@@ -316,6 +316,15 @@ class JSONParser:
316
316
  next_c = self.get_char_at(i)
317
317
  if next_c and next_c in [",", "}"]:
318
318
  rstring_delimiter_missing = False
319
+ elif char == ",":
320
+ # We couldn't find any rstring_delimeter before the end of the string
321
+ # check if this is the last string of an object and therefore we can keep going
322
+ # make an exception if this is the last char before the closing brace
323
+ i = self.skip_to_character(character="}", idx=1)
324
+ if i > 1:
325
+ # Ok it's not right after the comma
326
+ # Let's ignore
327
+ rstring_delimiter_missing = False
319
328
  if rstring_delimiter_missing:
320
329
  self.log(
321
330
  "While parsing a string missing the left delimiter in object value context, we found a , or } and we couldn't determine that a right delimiter was present. Stopping here",
@@ -424,7 +433,9 @@ class JSONParser:
424
433
  string_acc += str(char)
425
434
  self.index += 1
426
435
  char = self.get_char_at()
427
- elif next_c == rstring_delimiter:
436
+ elif (
437
+ next_c == rstring_delimiter and self.get_char_at(i - 1) != "\\"
438
+ ):
428
439
  if self.context.current == ContextValues.OBJECT_VALUE:
429
440
  # But this might not be it! This could be just a missing comma
430
441
  # We found a delimiter and we need to check if this is a key
@@ -436,11 +447,10 @@ class JSONParser:
436
447
  i += 1
437
448
  next_c = self.get_char_at(i)
438
449
  while next_c and next_c != ":":
439
- if next_c in [
440
- lstring_delimiter,
441
- rstring_delimiter,
442
- ",",
443
- ]:
450
+ if next_c == "," or (
451
+ next_c == rstring_delimiter
452
+ and self.get_char_at(i - 1) != "\\"
453
+ ):
444
454
  break
445
455
  i += 1
446
456
  next_c = self.get_char_at(i)
@@ -569,6 +579,9 @@ class JSONParser:
569
579
  char = self.json_str[self.index + idx]
570
580
  except IndexError:
571
581
  return idx
582
+ if self.index + idx > 0 and self.json_str[self.index + idx - 1] == "\\":
583
+ # Ah this is an escaped character, try again
584
+ return self.skip_to_character(character=character, idx=idx + 1)
572
585
  return idx
573
586
 
574
587
  def _log(self, text: str) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.29.4
3
+ Version: 0.29.6
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
@@ -140,6 +140,7 @@ def test_object_edge_cases():
140
140
  assert repair_json('{"key": "Lorem "ipsum" s,"}') == '{"key": "Lorem \\"ipsum\\" s,"}'
141
141
  assert repair_json('{"lorem": ipsum, sic, datum.",}') == '{"lorem": "ipsum, sic, datum."}'
142
142
  assert repair_json('{"lorem": sic tamet. "ipsum": sic tamet, quick brown fox. "sic": ipsum}') == '{"lorem": "sic tamet.", "ipsum": "sic tamet", "sic": "ipsum"}'
143
+ assert repair_json('{"lorem_ipsum": "sic tamet, quick brown fox. }') == '{"lorem_ipsum": "sic tamet, quick brown fox."}'
143
144
  assert repair_json('{"key":value, " key2":"value2" }') == '{"key": "value", " key2": "value2"}'
144
145
  assert repair_json('{"key":value "key2":"value2" }') == '{"key": "value", "key2": "value2"}'
145
146
 
File without changes
File without changes
File without changes