json-repair 0.42.0__py3-none-any.whl → 0.43.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_parser.py +23 -2
- {json_repair-0.42.0.dist-info → json_repair-0.43.0.dist-info}/METADATA +1 -1
- {json_repair-0.42.0.dist-info → json_repair-0.43.0.dist-info}/RECORD +7 -7
- {json_repair-0.42.0.dist-info → json_repair-0.43.0.dist-info}/WHEEL +1 -1
- {json_repair-0.42.0.dist-info → json_repair-0.43.0.dist-info}/entry_points.txt +0 -0
- {json_repair-0.42.0.dist-info → json_repair-0.43.0.dist-info}/licenses/LICENSE +0 -0
- {json_repair-0.42.0.dist-info → json_repair-0.43.0.dist-info}/top_level.txt +0 -0
json_repair/json_parser.py
CHANGED
@@ -113,7 +113,7 @@ class JSONParser:
|
|
113
113
|
|
114
114
|
def parse_object(self) -> Dict[str, JSONReturnType]:
|
115
115
|
# <object> ::= '{' [ <member> *(', ' <member>) ] '}' ; A sequence of 'members'
|
116
|
-
obj = {}
|
116
|
+
obj: Dict[str, JSONReturnType] = {}
|
117
117
|
# Stop when you either find the closing parentheses or you have iterated over the entire string
|
118
118
|
while (self.get_char_at() or "}") != "}":
|
119
119
|
# This is what we expect to find:
|
@@ -141,6 +141,27 @@ class JSONParser:
|
|
141
141
|
while self.get_char_at():
|
142
142
|
# The rollback index needs to be updated here in case the key is empty
|
143
143
|
rollback_index = self.index
|
144
|
+
if self.get_char_at() == "[" and key == "":
|
145
|
+
# Is this an array?
|
146
|
+
# Need to check if the previous parsed value contained in obj is an array and in that case parse and merge the two
|
147
|
+
prev_key = list(obj.keys())[-1] if obj else None
|
148
|
+
if prev_key and isinstance(obj[prev_key], list):
|
149
|
+
# If the previous key's value is an array, parse the new array and merge
|
150
|
+
self.index += 1
|
151
|
+
new_array = self.parse_array()
|
152
|
+
if isinstance(new_array, list):
|
153
|
+
# Merge and flatten the arrays
|
154
|
+
prev_value = obj[prev_key]
|
155
|
+
if isinstance(prev_value, list):
|
156
|
+
prev_value.extend(
|
157
|
+
new_array[0]
|
158
|
+
if len(new_array) == 1
|
159
|
+
and isinstance(new_array[0], list)
|
160
|
+
else new_array
|
161
|
+
)
|
162
|
+
continue
|
163
|
+
else:
|
164
|
+
self.index = rollback_index
|
144
165
|
key = str(self.parse_string())
|
145
166
|
if key == "":
|
146
167
|
self.skip_whitespaces_at()
|
@@ -216,7 +237,7 @@ class JSONParser:
|
|
216
237
|
|
217
238
|
# skip over whitespace after a value but before closing ]
|
218
239
|
char = self.get_char_at()
|
219
|
-
while char and (char.isspace() or char == ","):
|
240
|
+
while char and char != "]" and (char.isspace() or char == ","):
|
220
241
|
self.index += 1
|
221
242
|
char = self.get_char_at()
|
222
243
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
json_repair/__init__.py,sha256=c4L2kZrHvWEKfj_ODU2naliNuvU6FlFVxtF0hbLe6s8,178
|
2
2
|
json_repair/__main__.py,sha256=EsJb-y89uZEvGQQg1GdIDWzfDwfOMvVekKEtdguQXCM,67
|
3
3
|
json_repair/json_context.py,sha256=mm6dOyrPJ1sDskTORZSXCW7W9-5veMlUKqXQ3Hw3EG4,971
|
4
|
-
json_repair/json_parser.py,sha256=
|
4
|
+
json_repair/json_parser.py,sha256=GFziN2KELYDWElzPda5wPfSeFIHYF8enJSr0c2YzKmQ,40451
|
5
5
|
json_repair/json_repair.py,sha256=k-5HRRlCqrxNmJi0u1KE3IUeL4HXqi1XZ7oAL-NFDLo,10314
|
6
6
|
json_repair/object_comparer.py,sha256=SeicB6_N4BHAEPon7s2BELEaJc4oyR9ZhfX2RgPk6Bw,1682
|
7
7
|
json_repair/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
json_repair/string_file_wrapper.py,sha256=koZmdq2-Z5K7XF1bDqX6dEbNaVMJYcMTjq-aGe6NQvA,4526
|
9
|
-
json_repair-0.
|
10
|
-
json_repair-0.
|
11
|
-
json_repair-0.
|
12
|
-
json_repair-0.
|
13
|
-
json_repair-0.
|
14
|
-
json_repair-0.
|
9
|
+
json_repair-0.43.0.dist-info/licenses/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
10
|
+
json_repair-0.43.0.dist-info/METADATA,sha256=fR8K3LENGHxwkjG2pVRedVsh6XGBq0JWPV3weLz1KIM,11860
|
11
|
+
json_repair-0.43.0.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
|
12
|
+
json_repair-0.43.0.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
|
13
|
+
json_repair-0.43.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
14
|
+
json_repair-0.43.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|