json-repair 0.26.0__tar.gz → 0.27.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.26.0
3
+ Version: 0.27.1
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.26.0"
6
+ version = "0.27.1"
7
7
  license = {file = "LICENSE"}
8
8
  authors = [
9
9
  { name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
@@ -301,7 +301,7 @@ class JSONParser:
301
301
 
302
302
  char = self.get_char_at()
303
303
  # A valid string can only start with a valid quote or, in our case, with a literal
304
- while char and char not in ['"', "'", "“"] and not char.isalpha():
304
+ while char and char not in ['"', "'", "“"] and not char.isalnum():
305
305
  self.index += 1
306
306
  char = self.get_char_at()
307
307
 
@@ -315,7 +315,7 @@ class JSONParser:
315
315
  elif char == "“":
316
316
  lstring_delimiter = "“"
317
317
  rstring_delimiter = "”"
318
- elif char.isalpha():
318
+ elif char.isalnum():
319
319
  # This could be a <boolean> and not a string. Because (T)rue or (F)alse or (N)ull are valid
320
320
  # But remember, object keys are only of type string
321
321
  if char.lower() in ["t", "f", "n"] and self.get_context() != "object_key":
@@ -412,7 +412,7 @@ class JSONParser:
412
412
  string_acc += char
413
413
  self.index += 1
414
414
  char = self.get_char_at()
415
- if len(string_acc) > 1 and string_acc[-1] == "\\":
415
+ if len(string_acc) > 0 and string_acc[-1] == "\\":
416
416
  # This is a special case, if people use real strings this might happen
417
417
  self.log("Found a stray escape sequence, normalizing it", "info")
418
418
  string_acc = string_acc[:-1]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.26.0
3
+ Version: 0.27.1
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
@@ -96,6 +96,8 @@ def test_missing_and_mixed_quotes():
96
96
  )
97
97
  assert repair_json('[{"key": "value", COMMENT "notes": "lorem "ipsum", sic."}]') == '[{"key": "value", "notes": "lorem \\"ipsum\\", sic."}]'
98
98
  assert repair_json('{"key": ""value"}') == '{"key": "value"}'
99
+ assert repair_json('{"key": "value", 5: "value"}') == '{"key": "value", "5": "value"}'
100
+ assert repair_json('{"foo": "\\"bar\\""') == '{"foo": "\\"bar\\""}'
99
101
 
100
102
  def test_array_edge_cases():
101
103
  assert repair_json("[1, 2, 3,") == "[1, 2, 3]"
@@ -252,4 +254,4 @@ def test_repair_json_from_file():
252
254
  os.remove(temp_path)
253
255
 
254
256
  def test_ensure_ascii():
255
- assert repair_json("{'test_中国人_ascii':'统一码'}", ensure_ascii=False) == '{"test_中国人_ascii": "统一码"}'
257
+ assert repair_json("{'test_中国人_ascii':'统一码'}", ensure_ascii=False) == '{"test_中国人_ascii": "统一码"}'
File without changes
File without changes
File without changes