json-repair 0.25.3__py3-none-any.whl → 0.26.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.
- json_repair/json_repair.py +15 -5
- {json_repair-0.25.3.dist-info → json_repair-0.26.0.dist-info}/METADATA +3 -3
- json_repair-0.26.0.dist-info/RECORD +7 -0
- {json_repair-0.25.3.dist-info → json_repair-0.26.0.dist-info}/WHEEL +1 -1
- json_repair-0.25.3.dist-info/RECORD +0 -7
- {json_repair-0.25.3.dist-info → json_repair-0.26.0.dist-info}/LICENSE +0 -0
- {json_repair-0.25.3.dist-info → json_repair-0.26.0.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -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,
|
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(
|
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,
|
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.
|
3
|
+
Version: 0.26.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.
|
34
|
+
Requires-Python: >=3.8
|
35
35
|
Description-Content-Type: text/markdown
|
36
36
|
License-File: LICENSE
|
37
37
|
|
38
38
|
[](https://pypi.org/project/json-repair/)
|
39
|
-

|
40
40
|
[](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=OSRwsg96BbOzdgwN3BuynsIu1HxYt1oY4o3kebAXXhQ,31792
|
3
|
+
json_repair-0.26.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
+
json_repair-0.26.0.dist-info/METADATA,sha256=YZ4ccI-izYyi-SXujrNbSpD_Op0CDYAM7DTJ4K9Cfnw,7863
|
5
|
+
json_repair-0.26.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
6
|
+
json_repair-0.26.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
+
json_repair-0.26.0.dist-info/RECORD,,
|
@@ -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,,
|
File without changes
|
File without changes
|