json-repair 0.52.2__py3-none-any.whl → 0.52.4__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.
@@ -81,6 +81,7 @@ class JSONParser:
81
81
  )
82
82
  json = [json]
83
83
  while self.index < len(self.json_str):
84
+ self.context.reset()
84
85
  j = self.parse_json()
85
86
  if j != "":
86
87
  if ObjectComparer.is_same_object(json[-1], j):
@@ -193,7 +193,7 @@ def parse_string(self: "JSONParser") -> JSONReturnType:
193
193
  not self.stream_stable
194
194
  and char == "]"
195
195
  and ContextValues.ARRAY in self.context.context
196
- and string_acc[-1] != rstring_delimiter
196
+ and (not string_acc or string_acc[-1] != rstring_delimiter)
197
197
  ):
198
198
  # We found the end of an array and we are in array context
199
199
  # So let's check if we find a rstring_delimiter forward otherwise end early
@@ -226,9 +226,9 @@ def parse_string(self: "JSONParser") -> JSONReturnType:
226
226
  self.index += 1
227
227
  char = self.get_char_at()
228
228
  # Unclosed string ends with a \ character. This character is ignored if stream_stable = True.
229
- if self.stream_stable and not char and string_acc[-1] == "\\":
229
+ if self.stream_stable and not char and string_acc and string_acc[-1] == "\\":
230
230
  string_acc = string_acc[:-1]
231
- if char and string_acc[-1] == "\\":
231
+ if char and string_acc and string_acc[-1] == "\\":
232
232
  # This is a special case, if people use real strings this might happen
233
233
  self.log("Found a stray escape sequence, normalizing it")
234
234
  if char in [rstring_delimiter, "t", "n", "r", "b", "\\"]:
@@ -237,7 +237,7 @@ def parse_string(self: "JSONParser") -> JSONReturnType:
237
237
  string_acc += escape_seqs.get(char, char)
238
238
  self.index += 1
239
239
  char = self.get_char_at()
240
- while char and string_acc[-1] == "\\" and char in [rstring_delimiter, "\\"]:
240
+ while char and string_acc and string_acc[-1] == "\\" and char in [rstring_delimiter, "\\"]:
241
241
  # this is a bit of a special case, if I don't do this it will close the loop or create a train of \\
242
242
  # I don't love it though
243
243
  string_acc = string_acc[:-1] + char
@@ -289,7 +289,7 @@ def parse_string(self: "JSONParser") -> JSONReturnType:
289
289
  )
290
290
  break
291
291
  # ChatGPT sometimes forget to quote stuff in html tags or markdown, so we do this whole thing here
292
- if char == rstring_delimiter and string_acc[-1] != "\\":
292
+ if char == rstring_delimiter and string_acc and string_acc[-1] != "\\":
293
293
  # Special case here, in case of double quotes one after another
294
294
  if doubled_quotes and self.get_char_at(1) == rstring_delimiter:
295
295
  self.log("While parsing a string, we found a doubled quote, ignoring it")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: json_repair
3
- Version: 0.52.2
3
+ Version: 0.52.4
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
@@ -2,7 +2,7 @@ json_repair/__init__.py,sha256=JdJIZNCKV3MfIviryqK8NH8yGssCta2-192CekcwH-o,174
2
2
  json_repair/__main__.py,sha256=EsJb-y89uZEvGQQg1GdIDWzfDwfOMvVekKEtdguQXCM,67
3
3
  json_repair/constants.py,sha256=cv2gvyosuq0me0600WyTysM9avrtfXPuXYR26tawcuo,158
4
4
  json_repair/json_context.py,sha256=WsMOjqpGSr6aaDONcrk8UFtTurzWon2Qq9AoBBYseoI,934
5
- json_repair/json_parser.py,sha256=E5_xTtkLy4cNo2bgsBuGkQkpaL7NqJgODgWU_9rCEmE,7637
5
+ json_repair/json_parser.py,sha256=S4Ogczq42CiYbuF06EsDGkVJx05ePgTvrKIUQsZrBzM,7674
6
6
  json_repair/json_repair.py,sha256=sDhXzDZxu0QmaFzICPTtf_q7yOY1A1Lf_iQG6Potsco,11572
7
7
  json_repair/object_comparer.py,sha256=XKV3MRab8H7_v4sm-wpEa5le0XX9OeycWo5S-MFm-GI,1716
8
8
  json_repair/parse_array.py,sha256=-rh65JcfT-FtXiR6s8RYlMfI-6LzVr08ytlDh6Z2CFE,2181
@@ -10,12 +10,12 @@ json_repair/parse_boolean_or_null.py,sha256=WMSkvvxsp4wvauBcDqtt9WnLMD5SMoxeRfZF
10
10
  json_repair/parse_comment.py,sha256=JHtQ_QlxOvPNnMh7lhUaoTjFGelqjhTNq7qn9xUE7SU,2648
11
11
  json_repair/parse_number.py,sha256=33zAtkbuVzi9Lqjxu7cXn9WlVzd3WjRx9Ln_LFzVL4o,1259
12
12
  json_repair/parse_object.py,sha256=xMpO64sYW0JmUtW75BTD0EdPQjY7PYVgu4tHVXrWB6s,5582
13
- json_repair/parse_string.py,sha256=dx4ahhp-BU7HjTxoJ5eH_wh9SlMQgatZ4AqIq33sPKA,25606
13
+ json_repair/parse_string.py,sha256=banF0nNbONvO4C_SDQMDuCZO99UIQvKzRVki9xWVpfU,25686
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.52.2.dist-info/licenses/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
17
- json_repair-0.52.2.dist-info/METADATA,sha256=29Iqjqth0jDe1zZWV8DjLs4oQ_knABpE63Yyktbxwto,11027
18
- json_repair-0.52.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
- json_repair-0.52.2.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
20
- json_repair-0.52.2.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
21
- json_repair-0.52.2.dist-info/RECORD,,
16
+ json_repair-0.52.4.dist-info/licenses/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
17
+ json_repair-0.52.4.dist-info/METADATA,sha256=x1rE0e8rADu8qoy4k4vE2iKEamEsfh-ykMu7xMngX7I,11027
18
+ json_repair-0.52.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ json_repair-0.52.4.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
20
+ json_repair-0.52.4.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
21
+ json_repair-0.52.4.dist-info/RECORD,,