json-repair 0.25.3__py3-none-any.whl → 0.27.0__py3-none-any.whl

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.
@@ -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":
@@ -675,6 +675,7 @@ def repair_json(
675
675
  skip_json_loads: Optional[bool] = False,
676
676
  logging: Optional[bool] = False,
677
677
  json_fd: Optional[TextIO] = None,
678
+ ensure_ascii: Optional[bool] = True,
678
679
  ) -> Union[JSONReturnType, Tuple[JSONReturnType, List[Dict[str, str]]]]:
679
680
  """
680
681
  Given a json formatted string, it will try to decode it and, if it fails, it will try to fix it.
@@ -697,11 +698,13 @@ def repair_json(
697
698
  # It's useful to return the actual object instead of the json string, it allows this lib to be a replacement of the json library
698
699
  if return_objects or logging:
699
700
  return parsed_json
700
- return json.dumps(parsed_json)
701
+ return json.dumps(parsed_json, ensure_ascii=ensure_ascii)
701
702
 
702
703
 
703
704
  def loads(
704
- json_str: str, skip_json_loads: bool = False, logging: bool = False
705
+ json_str: str,
706
+ skip_json_loads: Optional[bool] = False,
707
+ logging: Optional[bool] = False,
705
708
  ) -> Union[JSONReturnType, Tuple[JSONReturnType, List[Dict[str, str]]]]:
706
709
  """
707
710
  This function works like `json.loads()` except that it will fix your JSON in the process.
@@ -716,17 +719,24 @@ def loads(
716
719
 
717
720
 
718
721
  def load(
719
- fd: TextIO, skip_json_loads: bool = False, logging: bool = False
722
+ fd: TextIO, skip_json_loads: Optional[bool] = False, logging: Optional[bool] = False
720
723
  ) -> Union[JSONReturnType, Tuple[JSONReturnType, List[Dict[str, str]]]]:
721
724
  """
722
725
  This function works like `json.load()` except that it will fix your JSON in the process.
723
726
  It is a wrapper around the `repair_json()` function with `json_fd=fd` and `return_objects=True`.
724
727
  """
725
- return repair_json(json_fd=fd, skip_json_loads=skip_json_loads, logging=logging)
728
+ return repair_json(
729
+ json_fd=fd,
730
+ return_objects=True,
731
+ skip_json_loads=skip_json_loads,
732
+ logging=logging,
733
+ )
726
734
 
727
735
 
728
736
  def from_file(
729
- filename: str, skip_json_loads: bool = False, logging: bool = False
737
+ filename: str,
738
+ skip_json_loads: Optional[bool] = False,
739
+ logging: Optional[bool] = False,
730
740
  ) -> Union[JSONReturnType, Tuple[JSONReturnType, List[Dict[str, str]]]]:
731
741
  """
732
742
  This function is a wrapper around `load()` so you can pass the filename as string
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.25.3
3
+ Version: 0.27.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
@@ -31,12 +31,12 @@ Keywords: JSON,REPAIR,LLM,PARSER
31
31
  Classifier: Programming Language :: Python :: 3
32
32
  Classifier: License :: OSI Approved :: MIT License
33
33
  Classifier: Operating System :: OS Independent
34
- Requires-Python: >=3.7
34
+ Requires-Python: >=3.8
35
35
  Description-Content-Type: text/markdown
36
36
  License-File: LICENSE
37
37
 
38
38
  [![PyPI](https://img.shields.io/pypi/v/json-repair)](https://pypi.org/project/json-repair/)
39
- ![Python version](https://img.shields.io/badge/python-3.7+-important)
39
+ ![Python version](https://img.shields.io/badge/python-3.8+-important)
40
40
  [![PyPI downloads](https://img.shields.io/pypi/dm/json-repair)](https://pypi.org/project/json-repair/)
41
41
 
42
42
 
@@ -0,0 +1,7 @@
1
+ json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
+ json_repair/json_repair.py,sha256=f3CYSD1B2fHC5CG3dkZszqExgYifo2-Bz-9ahapgbDc,31792
3
+ json_repair-0.27.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
+ json_repair-0.27.0.dist-info/METADATA,sha256=9Imy3Kvz12w7dEs5OBUX6k_REfYdSVLqrywzTGUJ500,7863
5
+ json_repair-0.27.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
6
+ json_repair-0.27.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
+ json_repair-0.27.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.3.0)
2
+ Generator: setuptools (72.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,7 +0,0 @@
1
- json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
- json_repair/json_repair.py,sha256=0_vEOcEDZ_MySf_6pyqWPzXKyLZTDPxOwyFSoqu9S8M,31586
3
- json_repair-0.25.3.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
- json_repair-0.25.3.dist-info/METADATA,sha256=AFNOs4gVCu9m-hbsx0FayipLhGixE_GJpsVwgxyjOVE,7863
5
- json_repair-0.25.3.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
6
- json_repair-0.25.3.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
- json_repair-0.25.3.dist-info/RECORD,,