json-repair 0.18.0__py3-none-any.whl → 0.19.1__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.
@@ -178,7 +178,12 @@ class JSONParser:
178
178
  if not value:
179
179
  break
180
180
 
181
- arr.append(value)
181
+ if value == "..." and self.get_char_at(-1) == ".":
182
+ self.log(
183
+ "While parsing an array, found a stray '...'; ignoring it", "info"
184
+ )
185
+ else:
186
+ arr.append(value)
182
187
 
183
188
  # skip over whitespace after a value but before closing ]
184
189
  char = self.get_char_at()
@@ -304,6 +309,15 @@ class JSONParser:
304
309
  string_acc += char
305
310
  self.index += 1
306
311
  char = self.get_char_at()
312
+ if len(string_acc) > 1 and string_acc[-1] == "\\":
313
+ # This is a special case, if people use real strings this might happen
314
+ self.log("Found a stray escape sequence, normalizing it", "info")
315
+ string_acc = string_acc[:-1]
316
+ if char in [rstring_delimiter, "t", "n", "r", "b", "\\"]:
317
+ escape_seqs = {"t": "\t", "n": "\n", "r": "\r", "b": "\b"}
318
+ string_acc += escape_seqs.get(char, char)
319
+ self.index += 1
320
+ char = self.get_char_at()
307
321
  # ChatGPT sometimes forget to quote stuff in html tags or markdown, so we do this whole thing here
308
322
  if char == rstring_delimiter:
309
323
  # Special case here, in case of double quotes one after another
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.18.0
3
+ Version: 0.19.1
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
@@ -0,0 +1,7 @@
1
+ json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
+ json_repair/json_repair.py,sha256=5viwB7G8T9EyYRsJpCxZPZChmgDkaT1WQ7oxFUjm5Lg,24349
3
+ json_repair-0.19.1.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
+ json_repair-0.19.1.dist-info/METADATA,sha256=FlAtvarNR4sXKlNYr7VDedyScl7t8UgqyDyNZ2NIS10,7333
5
+ json_repair-0.19.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ json_repair-0.19.1.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
+ json_repair-0.19.1.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
- json_repair/json_repair.py,sha256=HTeKyorj6ennan9ToprV-Hub633U76qgvXExm0mclnE,23559
3
- json_repair-0.18.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
- json_repair-0.18.0.dist-info/METADATA,sha256=YLFJ8IMcWYfNIxSMGhpGHuO_m49JXa1tcDDFAeZPJys,7333
5
- json_repair-0.18.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- json_repair-0.18.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
- json_repair-0.18.0.dist-info/RECORD,,