json-repair 0.22.0__py3-none-any.whl → 0.23.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 +20 -10
- {json_repair-0.22.0.dist-info → json_repair-0.23.0.dist-info}/METADATA +1 -1
- json_repair-0.23.0.dist-info/RECORD +7 -0
- json_repair-0.22.0.dist-info/RECORD +0 -7
- {json_repair-0.22.0.dist-info → json_repair-0.23.0.dist-info}/LICENSE +0 -0
- {json_repair-0.22.0.dist-info → json_repair-0.23.0.dist-info}/WHEEL +0 -0
- {json_repair-0.22.0.dist-info → json_repair-0.23.0.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -89,10 +89,25 @@ class JSONParser:
|
|
89
89
|
def parse(
|
90
90
|
self,
|
91
91
|
) -> Union[JSONReturnType, Tuple[JSONReturnType, List[Dict[str, str]]]]:
|
92
|
+
json = self.parse_json()
|
93
|
+
if self.index < len(self.json_str):
|
94
|
+
json = [json]
|
95
|
+
last_index = self.index
|
96
|
+
while self.index < len(self.json_str):
|
97
|
+
j = self.parse_json()
|
98
|
+
if j != "":
|
99
|
+
json.append(j)
|
100
|
+
if self.index == last_index:
|
101
|
+
self.index += 1
|
102
|
+
last_index = self.index
|
103
|
+
if len(json) == 1:
|
104
|
+
json = json[0]
|
105
|
+
elif len(json) == 0:
|
106
|
+
json = ""
|
92
107
|
if self.logger.log_level == "none":
|
93
|
-
return
|
108
|
+
return json
|
94
109
|
else:
|
95
|
-
return
|
110
|
+
return json, self.logger.log
|
96
111
|
|
97
112
|
def parse_json(
|
98
113
|
self,
|
@@ -306,14 +321,6 @@ class JSONParser:
|
|
306
321
|
"While parsing a string, we found a literal instead of a quote",
|
307
322
|
"info",
|
308
323
|
)
|
309
|
-
if self.get_context() == "":
|
310
|
-
# A string literal in the wild isn't a valid json and not something we can fix
|
311
|
-
self.log(
|
312
|
-
"While parsing a string, we found a literal outside of context, ignoring it",
|
313
|
-
"info",
|
314
|
-
)
|
315
|
-
self.index += 1
|
316
|
-
return self.parse_json()
|
317
324
|
self.log(
|
318
325
|
"While parsing a string, we found no starting quote. Will add the quote back",
|
319
326
|
"info",
|
@@ -658,3 +665,6 @@ def from_file(
|
|
658
665
|
fd.close()
|
659
666
|
|
660
667
|
return jsonobj
|
668
|
+
|
669
|
+
|
670
|
+
repair_json("[]{}")
|
@@ -0,0 +1,7 @@
|
|
1
|
+
json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
|
2
|
+
json_repair/json_repair.py,sha256=XXnrrQxMpH2N-zSPHDqI24OaaQd3EyVSUJAgxpfEHfg,27651
|
3
|
+
json_repair-0.23.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
+
json_repair-0.23.0.dist-info/METADATA,sha256=xkGqObtmpYdxnYoTBzCPhM1g4xXcMlOjV3SuN4EO2LM,7333
|
5
|
+
json_repair-0.23.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
json_repair-0.23.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
+
json_repair-0.23.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=r3Vx2rhFwqL201vXB5hgiJR2zLll_Rx4cn1_xKnLSTo,27501
|
3
|
-
json_repair-0.22.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
-
json_repair-0.22.0.dist-info/METADATA,sha256=D8wdIzgpU3n8Wzwv9_qCsiNsi5410vq7ouOR7l9zke0,7333
|
5
|
-
json_repair-0.22.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
json_repair-0.22.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
-
json_repair-0.22.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|