json-repair 0.29.4__py3-none-any.whl → 0.29.6__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -316,6 +316,15 @@ class JSONParser:
316
316
  next_c = self.get_char_at(i)
317
317
  if next_c and next_c in [",", "}"]:
318
318
  rstring_delimiter_missing = False
319
+ elif char == ",":
320
+ # We couldn't find any rstring_delimeter before the end of the string
321
+ # check if this is the last string of an object and therefore we can keep going
322
+ # make an exception if this is the last char before the closing brace
323
+ i = self.skip_to_character(character="}", idx=1)
324
+ if i > 1:
325
+ # Ok it's not right after the comma
326
+ # Let's ignore
327
+ rstring_delimiter_missing = False
319
328
  if rstring_delimiter_missing:
320
329
  self.log(
321
330
  "While parsing a string missing the left delimiter in object value context, we found a , or } and we couldn't determine that a right delimiter was present. Stopping here",
@@ -424,7 +433,9 @@ class JSONParser:
424
433
  string_acc += str(char)
425
434
  self.index += 1
426
435
  char = self.get_char_at()
427
- elif next_c == rstring_delimiter:
436
+ elif (
437
+ next_c == rstring_delimiter and self.get_char_at(i - 1) != "\\"
438
+ ):
428
439
  if self.context.current == ContextValues.OBJECT_VALUE:
429
440
  # But this might not be it! This could be just a missing comma
430
441
  # We found a delimiter and we need to check if this is a key
@@ -436,11 +447,10 @@ class JSONParser:
436
447
  i += 1
437
448
  next_c = self.get_char_at(i)
438
449
  while next_c and next_c != ":":
439
- if next_c in [
440
- lstring_delimiter,
441
- rstring_delimiter,
442
- ",",
443
- ]:
450
+ if next_c == "," or (
451
+ next_c == rstring_delimiter
452
+ and self.get_char_at(i - 1) != "\\"
453
+ ):
444
454
  break
445
455
  i += 1
446
456
  next_c = self.get_char_at(i)
@@ -569,6 +579,9 @@ class JSONParser:
569
579
  char = self.json_str[self.index + idx]
570
580
  except IndexError:
571
581
  return idx
582
+ if self.index + idx > 0 and self.json_str[self.index + idx - 1] == "\\":
583
+ # Ah this is an escaped character, try again
584
+ return self.skip_to_character(character=character, idx=idx + 1)
572
585
  return idx
573
586
 
574
587
  def _log(self, text: str) -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.29.4
3
+ Version: 0.29.6
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=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
2
  json_repair/__main__.py,sha256=EsJb-y89uZEvGQQg1GdIDWzfDwfOMvVekKEtdguQXCM,67
3
3
  json_repair/json_context.py,sha256=DdJu3DJR-ANvr8KrWfJqdtOE3uI6_B0VQidKvE3PjJA,1080
4
- json_repair/json_parser.py,sha256=BUPyAsb7wzkjNrBmsZgxgoOM9JhksCN-8cHcbJQpcPU,25525
4
+ json_repair/json_parser.py,sha256=6d8R2m29meyFz2_gxvF5olYs1VytAQTV-rDqIYzwjnE,26385
5
5
  json_repair/json_repair.py,sha256=GTg3OAXRbAJAHWs8oiQDqUHh4h6qKDVvWPXcrqafzLY,6100
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.29.4.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
9
- json_repair-0.29.4.dist-info/METADATA,sha256=dBmPfg4wBTxOFXklH4V38aiO4pUks5FS7HcvQlZ4NIg,10686
10
- json_repair-0.29.4.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
- json_repair-0.29.4.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
12
- json_repair-0.29.4.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
13
- json_repair-0.29.4.dist-info/RECORD,,
8
+ json_repair-0.29.6.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
9
+ json_repair-0.29.6.dist-info/METADATA,sha256=Us1Nn8o5yaJHnssGY5t7X1yfii0NRCvlSjBH9TyANnw,10686
10
+ json_repair-0.29.6.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
11
+ json_repair-0.29.6.dist-info/entry_points.txt,sha256=SNfge3zPSP-ASqriYU9r3NAPaXdseYr7ciPMKdV2uSw,57
12
+ json_repair-0.29.6.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
13
+ json_repair-0.29.6.dist-info/RECORD,,