json-repair 0.10.1__py3-none-any.whl → 0.11.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 +13 -6
- {json_repair-0.10.1.dist-info → json_repair-0.11.1.dist-info}/METADATA +6 -1
- json_repair-0.11.1.dist-info/RECORD +7 -0
- {json_repair-0.10.1.dist-info → json_repair-0.11.1.dist-info}/WHEEL +1 -1
- json_repair-0.10.1.dist-info/RECORD +0 -7
- {json_repair-0.10.1.dist-info → json_repair-0.11.1.dist-info}/LICENSE +0 -0
- {json_repair-0.10.1.dist-info → json_repair-0.11.1.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -209,10 +209,14 @@ class JSONParser:
|
|
209
209
|
break
|
210
210
|
self.index += 1
|
211
211
|
char = self.get_char_at()
|
212
|
-
# If the string contains escaped
|
213
|
-
if
|
214
|
-
|
215
|
-
|
212
|
+
# If the string contains an escaped character we should respect that or remove the escape
|
213
|
+
if self.get_char_at(-1) == "\\":
|
214
|
+
if char in [rstring_delimiter, "t", "n", "r", "b", "\\"]:
|
215
|
+
self.index += 1
|
216
|
+
char = self.get_char_at()
|
217
|
+
else:
|
218
|
+
self.remove_char_at(-1)
|
219
|
+
self.index -= 1
|
216
220
|
# ChatGPT sometimes forget to quote links in markdown like: { "content": "[LINK]("https://google.com")" }
|
217
221
|
if (
|
218
222
|
char == rstring_delimiter
|
@@ -288,8 +292,11 @@ class JSONParser:
|
|
288
292
|
except IndexError:
|
289
293
|
return False
|
290
294
|
|
291
|
-
def remove_char_at(self) -> None:
|
292
|
-
self.json_str =
|
295
|
+
def remove_char_at(self, count: int = 0) -> None:
|
296
|
+
self.json_str = (
|
297
|
+
self.json_str[: self.index + count]
|
298
|
+
+ self.json_str[self.index + count + 1 :]
|
299
|
+
)
|
293
300
|
|
294
301
|
def skip_whitespaces_at(self) -> None:
|
295
302
|
# Remove trailing spaces
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.11.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
|
@@ -127,3 +127,8 @@ You will need owner access to this repository
|
|
127
127
|
---
|
128
128
|
# Bonus Content
|
129
129
|
If you need some good Custom Instructions (System Message) to improve your chatbot responses try https://gist.github.com/mangiucugna/7ec015c4266df11be8aa510be0110fe4
|
130
|
+
|
131
|
+
---
|
132
|
+
## Star History
|
133
|
+
|
134
|
+
[](https://star-history.com/#mangiucugna/json_repair&Date)
|
@@ -0,0 +1,7 @@
|
|
1
|
+
json_repair/__init__.py,sha256=p9mZnte8Bg18NcxqgJ7vopH2gQv_XbZ0dRnk686QuRE,92
|
2
|
+
json_repair/json_repair.py,sha256=mzTDEwdp8hjrBL7R8RMZq17FHXwoEVaLtmi5b911dtQ,14071
|
3
|
+
json_repair-0.11.1.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
+
json_repair-0.11.1.dist-info/METADATA,sha256=p_-EC77JWz9T4_4FO_OBnslATx247y1nyN0EsyuGWaA,6580
|
5
|
+
json_repair-0.11.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
json_repair-0.11.1.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
+
json_repair-0.11.1.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
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,,
|
File without changes
|
File without changes
|