json-repair 0.32.0__tar.gz → 0.33.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (20) hide show
  1. {json_repair-0.32.0/src/json_repair.egg-info → json_repair-0.33.0}/PKG-INFO +1 -1
  2. {json_repair-0.32.0 → json_repair-0.33.0}/pyproject.toml +1 -1
  3. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair/json_parser.py +22 -2
  4. {json_repair-0.32.0 → json_repair-0.33.0/src/json_repair.egg-info}/PKG-INFO +1 -1
  5. {json_repair-0.32.0 → json_repair-0.33.0}/tests/test_json_repair.py +1 -0
  6. {json_repair-0.32.0 → json_repair-0.33.0}/LICENSE +0 -0
  7. {json_repair-0.32.0 → json_repair-0.33.0}/README.md +0 -0
  8. {json_repair-0.32.0 → json_repair-0.33.0}/setup.cfg +0 -0
  9. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair/__init__.py +0 -0
  10. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair/__main__.py +0 -0
  11. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair/json_context.py +0 -0
  12. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair/json_repair.py +0 -0
  13. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair/py.typed +0 -0
  14. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair/string_file_wrapper.py +0 -0
  15. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair.egg-info/SOURCES.txt +0 -0
  16. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair.egg-info/dependency_links.txt +0 -0
  17. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair.egg-info/entry_points.txt +0 -0
  18. {json_repair-0.32.0 → json_repair-0.33.0}/src/json_repair.egg-info/top_level.txt +0 -0
  19. {json_repair-0.32.0 → json_repair-0.33.0}/tests/test_coverage.py +0 -0
  20. {json_repair-0.32.0 → json_repair-0.33.0}/tests/test_performance.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.32.0
3
+ Version: 0.33.0
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.32.0"
6
+ version = "0.33.0"
7
7
  license = {file = "LICENSE"}
8
8
  authors = [
9
9
  { name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
@@ -508,9 +508,8 @@ class JSONParser:
508
508
  # But this might not be it! This could be just a missing comma
509
509
  # We found a delimiter and we need to check if this is a key
510
510
  # so find a rstring_delimiter and a colon after
511
- i += 1
512
511
  i = self.skip_to_character(
513
- character=rstring_delimiter, idx=i
512
+ character=rstring_delimiter, idx=i + 1
514
513
  )
515
514
  i += 1
516
515
  next_c = self.get_char_at(i)
@@ -531,6 +530,27 @@ class JSONParser:
531
530
  string_acc += str(char)
532
531
  self.index += 1
533
532
  char = self.get_char_at()
533
+ elif self.context.current == ContextValues.ARRAY:
534
+ # In array context this could be something like "lorem "ipsum" sic"
535
+ # So let's check if we find a rstring_delimiter forward otherwise end early
536
+ i = self.skip_to_character(rstring_delimiter, idx=i + 1)
537
+ next_c = self.get_char_at(i)
538
+ if next_c and next_c == rstring_delimiter:
539
+ # Ok now if I find a comma or a closing ], that can be have also an optional rstring_delimiter before them
540
+ # We can consider this a misplaced quote
541
+ i += 1
542
+ i = self.skip_whitespaces_at(
543
+ idx=i, move_main_index=False
544
+ )
545
+ next_c = self.get_char_at(i)
546
+ if next_c and next_c in [",", "]"]:
547
+ self.log(
548
+ "While parsing a string, we a misplaced quote that would have closed the string but has a different meaning here, ignoring it",
549
+ )
550
+ unmatched_delimiter = not unmatched_delimiter
551
+ string_acc += str(char)
552
+ self.index += 1
553
+ char = self.get_char_at()
534
554
 
535
555
  if (
536
556
  char
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.32.0
3
+ Version: 0.33.0
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
@@ -121,6 +121,7 @@ def test_array_edge_cases():
121
121
  assert repair_json('{"employees":["John", "Anna", "Peter') == '{"employees": ["John", "Anna", "Peter"]}'
122
122
  assert repair_json('{"key1": {"key2": [1, 2, 3') == '{"key1": {"key2": [1, 2, 3]}}'
123
123
  assert repair_json('{"key": ["value]}') == '{"key": ["value"]}'
124
+ assert repair_json('["lorem "ipsum" sic"]') == '["lorem \\"ipsum\\" sic"]'
124
125
 
125
126
  def test_escaping():
126
127
  assert repair_json("'\"'") == '""'
File without changes
File without changes
File without changes