json-repair 0.50.0__py3-none-any.whl → 0.51.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/parse_object.py +22 -1
- json_repair/parse_string.py +12 -9
- {json_repair-0.50.0.dist-info → json_repair-0.51.0.dist-info}/METADATA +3 -2
- {json_repair-0.50.0.dist-info → json_repair-0.51.0.dist-info}/RECORD +8 -8
- {json_repair-0.50.0.dist-info → json_repair-0.51.0.dist-info}/WHEEL +0 -0
- {json_repair-0.50.0.dist-info → json_repair-0.51.0.dist-info}/entry_points.txt +0 -0
- {json_repair-0.50.0.dist-info → json_repair-0.51.0.dist-info}/licenses/LICENSE +0 -0
- {json_repair-0.50.0.dist-info → json_repair-0.51.0.dist-info}/top_level.txt +0 -0
json_repair/parse_object.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import TYPE_CHECKING
|
2
2
|
|
3
|
-
from .constants import JSONReturnType
|
3
|
+
from .constants import STRING_DELIMITERS, JSONReturnType
|
4
4
|
from .json_context import ContextValues
|
5
5
|
|
6
6
|
if TYPE_CHECKING:
|
@@ -112,4 +112,25 @@ def parse_object(self: "JSONParser") -> dict[str, JSONReturnType]:
|
|
112
112
|
self.skip_whitespaces_at()
|
113
113
|
|
114
114
|
self.index += 1
|
115
|
+
|
116
|
+
# Check if there are more key-value pairs after the closing brace
|
117
|
+
# This handles cases like '{"key": "value"}, "key2": "value2"}'
|
118
|
+
# But only if we're not in a nested context
|
119
|
+
if not self.context.empty:
|
120
|
+
return obj
|
121
|
+
|
122
|
+
self.skip_whitespaces_at()
|
123
|
+
if (self.get_char_at() or "") != ",":
|
124
|
+
return obj
|
125
|
+
self.index += 1
|
126
|
+
self.skip_whitespaces_at()
|
127
|
+
if (self.get_char_at() or "") not in STRING_DELIMITERS:
|
128
|
+
return obj
|
129
|
+
self.log(
|
130
|
+
"Found a comma and string delimiter after object closing brace, checking for additional key-value pairs",
|
131
|
+
)
|
132
|
+
additional_obj = self.parse_object()
|
133
|
+
if isinstance(additional_obj, dict):
|
134
|
+
obj.update(additional_obj)
|
135
|
+
|
115
136
|
return obj
|
json_repair/parse_string.py
CHANGED
@@ -391,18 +391,21 @@ def parse_string(self: "JSONParser") -> str | bool | None:
|
|
391
391
|
self.index += 1
|
392
392
|
char = self.get_char_at()
|
393
393
|
elif self.context.current == ContextValues.ARRAY:
|
394
|
-
#
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
394
|
+
# So here we can have a few valid cases:
|
395
|
+
# ["bla bla bla "puppy" bla bla bla "kitty" bla bla"]
|
396
|
+
# ["value1" value2", "value3"]
|
397
|
+
# The basic idea is that if we find an even number of delimiters after this delimiter
|
398
|
+
# we ignore this delimiter as it should be fine
|
399
|
+
even_delimiters = next_c == rstring_delimiter
|
400
|
+
while next_c == rstring_delimiter:
|
399
401
|
i = self.skip_to_character(character=[rstring_delimiter, "]"], idx=i + 1)
|
402
|
+
next_c = self.get_char_at(i)
|
403
|
+
if next_c != rstring_delimiter:
|
404
|
+
even_delimiters = False
|
405
|
+
break
|
400
406
|
i = self.skip_to_character(character=[rstring_delimiter, "]"], idx=i + 1)
|
401
407
|
next_c = self.get_char_at(i)
|
402
|
-
|
403
|
-
# next_c = self.get_char_at(i)
|
404
|
-
# if next_c in [",", "]"]:
|
405
|
-
if even_delimiters and next_c != "]":
|
408
|
+
if even_delimiters:
|
406
409
|
# If we got up to here it means that this is a situation like this:
|
407
410
|
# ["bla bla bla "puppy" bla bla bla "kitty" bla bla"]
|
408
411
|
# So we need to ignore this quote
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: json_repair
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.51.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-Expression: MIT
|
@@ -17,7 +17,7 @@ Dynamic: license-file
|
|
17
17
|
|
18
18
|
[](https://pypi.org/project/json-repair/)
|
19
19
|

|
20
|
-
[](https://pypi.org/project/json-repair/)
|
21
21
|
[](https://pepy.tech/projects/json-repair)
|
22
22
|
[](https://github.com/sponsors/mangiucugna)
|
23
23
|
[](https://github.com/mangiucugna/json_repair/stargazers)
|
@@ -269,6 +269,7 @@ You will need owner access to this repository
|
|
269
269
|
- Ruby: https://github.com/sashazykov/json-repair-rb
|
270
270
|
- Rust: https://github.com/oramasearch/llm_json
|
271
271
|
- R: https://github.com/cgxjdzz/jsonRepair
|
272
|
+
- Java: https://github.com/du00cs/json-repairj
|
272
273
|
---
|
273
274
|
## Star History
|
274
275
|
|
@@ -9,13 +9,13 @@ json_repair/parse_array.py,sha256=-rh65JcfT-FtXiR6s8RYlMfI-6LzVr08ytlDh6Z2CFE,21
|
|
9
9
|
json_repair/parse_boolean_or_null.py,sha256=WMSkvvxsp4wvauBcDqtt9WnLMD5SMoxeRfZFXp3FEBc,890
|
10
10
|
json_repair/parse_comment.py,sha256=JHtQ_QlxOvPNnMh7lhUaoTjFGelqjhTNq7qn9xUE7SU,2648
|
11
11
|
json_repair/parse_number.py,sha256=33zAtkbuVzi9Lqjxu7cXn9WlVzd3WjRx9Ln_LFzVL4o,1259
|
12
|
-
json_repair/parse_object.py,sha256=
|
13
|
-
json_repair/parse_string.py,sha256=
|
12
|
+
json_repair/parse_object.py,sha256=mdqJyzcmQkfSdveEHtHeHKZ-rp6vtOItPZIJTaRw1Ps,5294
|
13
|
+
json_repair/parse_string.py,sha256=7PX7eIjez6-y2Dgl2njxRC7FyV-j-WmW6RVhlXrDEfk,24379
|
14
14
|
json_repair/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
15
|
json_repair/string_file_wrapper.py,sha256=tGkWBEUPE-CZPf4uSM5NE9oSDTpskX0myJiXsl-gbds,4333
|
16
|
-
json_repair-0.
|
17
|
-
json_repair-0.
|
18
|
-
json_repair-0.
|
19
|
-
json_repair-0.
|
20
|
-
json_repair-0.
|
21
|
-
json_repair-0.
|
16
|
+
json_repair-0.51.0.dist-info/licenses/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
17
|
+
json_repair-0.51.0.dist-info/METADATA,sha256=-2zv0Wv1_DWydipYbNIRav0C-oXSeS7HpDXJggyhMYw,11027
|
18
|
+
json_repair-0.51.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
19
|
+
json_repair-0.51.0.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
|
20
|
+
json_repair-0.51.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
21
|
+
json_repair-0.51.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|