json-repair 0.46.2__py3-none-any.whl → 0.47.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.
@@ -365,13 +365,14 @@ class JSONParser:
365
365
  )
366
366
  break
367
367
  if (
368
- (missing_quotes or not self.stream_stable)
368
+ not self.stream_stable
369
369
  and self.context.current == ContextValues.OBJECT_VALUE
370
370
  and char
371
371
  in [
372
372
  ",",
373
373
  "}",
374
374
  ]
375
+ and string_acc[-1] != rstring_delimiter
375
376
  ):
376
377
  rstring_delimiter_missing = True
377
378
  # check if this is a case in which the closing comma is NOT missing instead
@@ -434,9 +435,10 @@ class JSONParser:
434
435
  )
435
436
  break
436
437
  if (
437
- (missing_quotes or not self.stream_stable)
438
+ not self.stream_stable
438
439
  and char == "]"
439
440
  and ContextValues.ARRAY in self.context.context
441
+ and string_acc[-1] != rstring_delimiter
440
442
  ):
441
443
  # We found the end of an array and we are in array context
442
444
  # So let's check if we find a rstring_delimiter forward otherwise end early
@@ -456,9 +458,17 @@ class JSONParser:
456
458
  if char in [rstring_delimiter, "t", "n", "r", "b", "\\"]:
457
459
  string_acc = string_acc[:-1]
458
460
  escape_seqs = {"t": "\t", "n": "\n", "r": "\r", "b": "\b"}
459
- string_acc += escape_seqs.get(char, char) or char
461
+ string_acc += escape_seqs.get(char, char)
460
462
  self.index += 1
461
463
  char = self.get_char_at()
464
+ while char and string_acc[-1] == "\\" and char in [rstring_delimiter, "\\"]:
465
+ # this is a bit of a special case, if I don't do this it will close the loop or create a train of \\
466
+ # I don't love it though
467
+ string_acc = string_acc[:-1]
468
+ string_acc += char
469
+ self.index += 1
470
+ char = self.get_char_at()
471
+ continue
462
472
  elif char in ["u", "x"]:
463
473
  # If we find a unicode escape sequence, normalize it
464
474
  num_chars = 4 if char == "u" else 2
@@ -499,7 +509,7 @@ class JSONParser:
499
509
  )
500
510
  break
501
511
  # ChatGPT sometimes forget to quote stuff in html tags or markdown, so we do this whole thing here
502
- if char == rstring_delimiter:
512
+ if char == rstring_delimiter and string_acc[-1] != "\\":
503
513
  # Special case here, in case of double quotes one after another
504
514
  if doubled_quotes and self.get_char_at(1) == rstring_delimiter:
505
515
  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.46.2
3
+ Version: 0.47.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,14 +1,14 @@
1
1
  json_repair/__init__.py,sha256=6FDD6dEVM5Pb5o4Zodgw4ex30Hzy-YvNRy0vts9SQ4I,118
2
2
  json_repair/__main__.py,sha256=EsJb-y89uZEvGQQg1GdIDWzfDwfOMvVekKEtdguQXCM,67
3
3
  json_repair/json_context.py,sha256=WsMOjqpGSr6aaDONcrk8UFtTurzWon2Qq9AoBBYseoI,934
4
- json_repair/json_parser.py,sha256=B-DgJfyQOMHQ3F0RIBnltUGnGw0DFM-J7xOcLmCylVs,39744
4
+ json_repair/json_parser.py,sha256=YBi07AfBGoZ54locsc6j1Y7WfdretFzmt0wXDEWwRo8,40321
5
5
  json_repair/json_repair.py,sha256=pyH5fCkS1lyNPVjkqXerQ91lBz3eTHDPgV1QtnvJm-Y,11243
6
6
  json_repair/object_comparer.py,sha256=LlIF0MisRglzC-CiG5AxAEDCBWBHeJd-6uXYx0uRmCk,1175
7
7
  json_repair/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  json_repair/string_file_wrapper.py,sha256=tGkWBEUPE-CZPf4uSM5NE9oSDTpskX0myJiXsl-gbds,4333
9
- json_repair-0.46.2.dist-info/licenses/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
10
- json_repair-0.46.2.dist-info/METADATA,sha256=-EKRFk4rzF6I4EqFqEVfXJn7aPFrgFzdf1oCZfWgYLE,12208
11
- json_repair-0.46.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
- json_repair-0.46.2.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
13
- json_repair-0.46.2.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
14
- json_repair-0.46.2.dist-info/RECORD,,
9
+ json_repair-0.47.0.dist-info/licenses/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
10
+ json_repair-0.47.0.dist-info/METADATA,sha256=HDyogQyOe0FUVMSnZ-_wm9HlOzXWkRyp4zjQPgZCfMU,12208
11
+ json_repair-0.47.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ json_repair-0.47.0.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
13
+ json_repair-0.47.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
14
+ json_repair-0.47.0.dist-info/RECORD,,