json-repair 0.10.1__tar.gz → 0.11.0__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.
- {json_repair-0.10.1/src/json_repair.egg-info → json_repair-0.11.0}/PKG-INFO +6 -1
- {json_repair-0.10.1 → json_repair-0.11.0}/README.md +5 -0
- {json_repair-0.10.1 → json_repair-0.11.0}/pyproject.toml +1 -1
- {json_repair-0.10.1 → json_repair-0.11.0}/src/json_repair/json_repair.py +12 -6
- {json_repair-0.10.1 → json_repair-0.11.0/src/json_repair.egg-info}/PKG-INFO +6 -1
- {json_repair-0.10.1 → json_repair-0.11.0}/tests/test_json_repair.py +1 -1
- {json_repair-0.10.1 → json_repair-0.11.0}/LICENSE +0 -0
- {json_repair-0.10.1 → json_repair-0.11.0}/setup.cfg +0 -0
- {json_repair-0.10.1 → json_repair-0.11.0}/src/json_repair/__init__.py +0 -0
- {json_repair-0.10.1 → json_repair-0.11.0}/src/json_repair.egg-info/SOURCES.txt +0 -0
- {json_repair-0.10.1 → json_repair-0.11.0}/src/json_repair.egg-info/dependency_links.txt +0 -0
- {json_repair-0.10.1 → json_repair-0.11.0}/src/json_repair.egg-info/top_level.txt +0 -0
- {json_repair-0.10.1 → json_repair-0.11.0}/tests/test_performance.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.11.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
|
@@ -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)
|
@@ -90,3 +90,8 @@ You will need owner access to this repository
|
|
90
90
|
---
|
91
91
|
# Bonus Content
|
92
92
|
If you need some good Custom Instructions (System Message) to improve your chatbot responses try https://gist.github.com/mangiucugna/7ec015c4266df11be8aa510be0110fe4
|
93
|
+
|
94
|
+
---
|
95
|
+
## Star History
|
96
|
+
|
97
|
+
[](https://star-history.com/#mangiucugna/json_repair&Date)
|
@@ -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.
|
6
|
+
version = "0.11.0"
|
7
7
|
license = {file = "LICENSE"}
|
8
8
|
authors = [
|
9
9
|
{ name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
|
@@ -209,10 +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
|
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)
|
216
219
|
# ChatGPT sometimes forget to quote links in markdown like: { "content": "[LINK]("https://google.com")" }
|
217
220
|
if (
|
218
221
|
char == rstring_delimiter
|
@@ -288,8 +291,11 @@ class JSONParser:
|
|
288
291
|
except IndexError:
|
289
292
|
return False
|
290
293
|
|
291
|
-
def remove_char_at(self) -> None:
|
292
|
-
self.json_str =
|
294
|
+
def remove_char_at(self, count: int = 0) -> None:
|
295
|
+
self.json_str = (
|
296
|
+
self.json_str[: self.index + count]
|
297
|
+
+ self.json_str[self.index + count + 1 :]
|
298
|
+
)
|
293
299
|
|
294
300
|
def skip_whitespaces_at(self) -> None:
|
295
301
|
# 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.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
|
@@ -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)
|
@@ -104,7 +104,7 @@ def test_repair_json():
|
|
104
104
|
```""") == '{"key": "value"}'
|
105
105
|
assert repair_json('````{ "key": "value" }```') == '{"key": "value"}'
|
106
106
|
assert repair_json(r'{"real_content": "Some string: Some other string Some string <a href=\"https://domain.com\">Some link</a>"') == r'{"real_content": "Some string: Some other string Some string <a href=\\\"https://domain.com\\\">Some link</a>"}'
|
107
|
-
|
107
|
+
assert repair_json('{"key\_1\n": "value"}') == '{"key_1\\n": "value"}'
|
108
108
|
|
109
109
|
|
110
110
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|