json-repair 0.10.0__py3-none-any.whl → 0.10.1__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 +5 -1
- {json_repair-0.10.0.dist-info → json_repair-0.10.1.dist-info}/METADATA +6 -6
- json_repair-0.10.1.dist-info/RECORD +7 -0
- json_repair-0.10.0.dist-info/RECORD +0 -7
- {json_repair-0.10.0.dist-info → json_repair-0.10.1.dist-info}/LICENSE +0 -0
- {json_repair-0.10.0.dist-info → json_repair-0.10.1.dist-info}/WHEEL +0 -0
- {json_repair-0.10.0.dist-info → json_repair-0.10.1.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -209,9 +209,13 @@ class JSONParser:
|
|
209
209
|
break
|
210
210
|
self.index += 1
|
211
211
|
char = self.get_char_at()
|
212
|
+
# If the string contains escaped delimiters we should respect that
|
213
|
+
if char == rstring_delimiter and self.get_char_at(-1) == "\\":
|
214
|
+
self.index += 1
|
215
|
+
char = self.get_char_at()
|
212
216
|
# ChatGPT sometimes forget to quote links in markdown like: { "content": "[LINK]("https://google.com")" }
|
213
217
|
if (
|
214
|
-
|
218
|
+
char == rstring_delimiter
|
215
219
|
# Next character is not a comma
|
216
220
|
and self.get_char_at(1) != ","
|
217
221
|
and (
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.10.
|
3
|
+
Version: 0.10.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
|
@@ -56,20 +56,20 @@ I searched for a lightweight python package that was able to reliably fix this p
|
|
56
56
|
You can use this library to completely replace `json.loads()`:
|
57
57
|
|
58
58
|
import json_repair
|
59
|
-
|
59
|
+
|
60
60
|
decoded_object = json_repair.loads(json_string)
|
61
61
|
|
62
62
|
or just
|
63
63
|
|
64
64
|
import json_repair
|
65
|
-
|
65
|
+
|
66
66
|
decoded_object = json_repair.repair_json(json_string, return_objects=True)
|
67
|
-
|
67
|
+
|
68
68
|
### Performance considerations
|
69
69
|
If you find this library too slow because is using `json.loads()` you can skip that by passing `skip_json_loads=True` to `repair_json`. Like:
|
70
70
|
|
71
71
|
from json_repair import repair_json
|
72
|
-
|
72
|
+
|
73
73
|
good_json_string = repair_json(bad_json_string, skip_json_loads=True)
|
74
74
|
|
75
75
|
I made a choice of not using any fast json library to avoid having any external dependency, so that anybody can use it regardless of their stack.
|
@@ -77,7 +77,7 @@ I made a choice of not using any fast json library to avoid having any external
|
|
77
77
|
Some rules of thumb to use:
|
78
78
|
- Setting `return_objects=True` will always be faster because the parser returns an object already and it doesn't have serialize that object to JSON
|
79
79
|
- `skip_json_loads` is faster only if you 100% know that the string is not a valid JSON
|
80
|
-
|
80
|
+
- If you are having issues with escaping pass the string as **raw** string like: `r"string with escaping\""`
|
81
81
|
## Adding to requirements
|
82
82
|
**Please pin this library only on the major version!**
|
83
83
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
json_repair/__init__.py,sha256=p9mZnte8Bg18NcxqgJ7vopH2gQv_XbZ0dRnk686QuRE,92
|
2
|
+
json_repair/json_repair.py,sha256=OIjr9L0CyysGrEEdfeeEkKoiFLaX2sGSnn2MYBqGHHo,13826
|
3
|
+
json_repair-0.10.1.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
+
json_repair-0.10.1.dist-info/METADATA,sha256=kPI-1mCI6HuVeV0eVV98GR5BS6Tk04tkxDkxKCdKG7E,6404
|
5
|
+
json_repair-0.10.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
6
|
+
json_repair-0.10.1.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
+
json_repair-0.10.1.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
json_repair/__init__.py,sha256=p9mZnte8Bg18NcxqgJ7vopH2gQv_XbZ0dRnk686QuRE,92
|
2
|
-
json_repair/json_repair.py,sha256=fGrOtUCgJmdmdk-ASpbTPritPGxGBTO_6IA7hCu-z0c,13629
|
3
|
-
json_repair-0.10.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
-
json_repair-0.10.0.dist-info/METADATA,sha256=CjwBF8L9xMpsNob3wr4nIdoIba3T4WmQ65Z6oisQM_4,6312
|
5
|
-
json_repair-0.10.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
6
|
-
json_repair-0.10.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
-
json_repair-0.10.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|