json-repair 0.30.3__py3-none-any.whl → 0.32.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,6 +124,9 @@ class JSONParser:
124
124
 
125
125
  self.skip_whitespaces_at()
126
126
 
127
+ # Save this index in case we need find a duplicate key
128
+ rollback_index = self.index
129
+
127
130
  # <member> starts with a <string>
128
131
  key = ""
129
132
  while self.get_char_at():
@@ -132,7 +135,14 @@ class JSONParser:
132
135
  if key != "" or (key == "" and self.get_char_at() == ":"):
133
136
  # If the string is empty but there is a object divider, we are done here
134
137
  break
138
+ if ContextValues.ARRAY in self.context.context and key in obj:
139
+ self.log(
140
+ "While parsing an object we found a duplicate key, closing the object here and rolling back the index",
141
+ )
142
+ self.index = rollback_index - 1
143
+ break
135
144
 
145
+ # Skip filler whitespaces
136
146
  self.skip_whitespaces_at()
137
147
 
138
148
  # We reached the end here
@@ -322,11 +332,24 @@ class JSONParser:
322
332
  else:
323
333
  # OK but this could still be some garbage at the end of the string
324
334
  # So we need to check if we find a new lstring_delimiter afterwards
325
- # If we do, this is a missing delimiter
335
+ # If we do, maybe this is a missing delimiter
326
336
  i = self.skip_to_character(character=lstring_delimiter, idx=i)
337
+ if doubled_quotes:
338
+ i = self.skip_to_character(
339
+ character=lstring_delimiter, idx=i
340
+ )
327
341
  next_c = self.get_char_at(i)
328
342
  if not next_c:
329
343
  rstring_delimiter_missing = False
344
+ else:
345
+ # But again, this could just be something a bit stupid like "lorem, "ipsum" sic"
346
+ # Check if we find a : afterwards (skipping space)
347
+ i = self.skip_whitespaces_at(
348
+ idx=i + 1, move_main_index=False
349
+ )
350
+ next_c = self.get_char_at(i)
351
+ if next_c and next_c != ":":
352
+ rstring_delimiter_missing = False
330
353
  else:
331
354
  # There could be a case in which even the next key:value is missing delimeters
332
355
  # because it might be a systemic issue with the output
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.30.3
3
+ Version: 0.32.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
@@ -1,13 +1,13 @@
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=Vdz3gUrweG4wh0Vh-xpv6HpFtoUH1Hc6Nu0b5smdcM0,29114
4
+ json_repair/json_parser.py,sha256=zOHJg9Uv-8-UkDV0curmcmqcH_hLOvyXVjitPCmE6Kw,30326
5
5
  json_repair/json_repair.py,sha256=LINLSJBs3cJMfs1YRDaIpfWR5PJLs87Oe06G5yQjY18,9729
6
6
  json_repair/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  json_repair/string_file_wrapper.py,sha256=EHLhNBWoyUitzT08thytYJiNZh_klEFwfT8zutPSdb4,3905
8
- json_repair-0.30.3.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
9
- json_repair-0.30.3.dist-info/METADATA,sha256=kUHN-HfYfhT0qCuh8KAKdhKI-vn4_tpSIsRTcN4xl8o,11794
10
- json_repair-0.30.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
11
- json_repair-0.30.3.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
12
- json_repair-0.30.3.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
13
- json_repair-0.30.3.dist-info/RECORD,,
8
+ json_repair-0.32.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
9
+ json_repair-0.32.0.dist-info/METADATA,sha256=Sbk5aG5bviThWyIXG4inuXPoJ9b0XNrAR1Hp-RVxdvY,11794
10
+ json_repair-0.32.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
11
+ json_repair-0.32.0.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
12
+ json_repair-0.32.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
13
+ json_repair-0.32.0.dist-info/RECORD,,