json-repair 0.19.2__py3-none-any.whl → 0.20.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.
@@ -335,32 +335,50 @@ class JSONParser:
335
335
  # Check if eventually there is a rstring delimiter, otherwise we bail
336
336
  i = 1
337
337
  next_c = self.get_char_at(i)
338
- while next_c and next_c != rstring_delimiter:
338
+ check_comma_in_object_value = True
339
+ while next_c and next_c not in [
340
+ rstring_delimiter,
341
+ lstring_delimiter,
342
+ ]:
343
+ # This is a bit of a weird workaround, essentially in object_value context we don't always break on commas
344
+ # This is because the routine after will make sure to correct any bad guess and this solves a corner case
345
+ if next_c.isalpha():
346
+ check_comma_in_object_value = False
339
347
  # If we are in an object context, let's check for the right delimiters
340
348
  if (
341
- next_c == lstring_delimiter
342
- or ("object_key" in self.context and next_c == ":")
343
- or ("object_value" in self.context and next_c in ["}", ","])
349
+ ("object_key" in self.context and next_c in [":", "}"])
350
+ or ("object_value" in self.context and next_c == "}")
344
351
  or ("array" in self.context and next_c in ["]", ","])
352
+ or (
353
+ check_comma_in_object_value
354
+ and self.get_context() == "object_value"
355
+ and next_c == ","
356
+ )
345
357
  ):
346
358
  break
347
359
  i += 1
348
360
  next_c = self.get_char_at(i)
349
361
  if next_c == rstring_delimiter:
350
- # But this might not be it! This could be just a missing comma
351
- # We need to check if we find a rstring_delimiter and a colon after
352
- i += 1
353
- next_c = self.get_char_at(i)
354
- while next_c and next_c != rstring_delimiter:
362
+ if self.get_context() == "object_value":
363
+ # But this might not be it! This could be just a missing comma
364
+ # We found a delimiter and we need to check if this is a key
365
+ # so find a rstring_delimiter and a colon after
355
366
  i += 1
356
367
  next_c = self.get_char_at(i)
357
- i += 1
358
- next_c = self.get_char_at(i)
359
- while next_c and next_c != ":":
360
- if next_c in [lstring_delimiter, rstring_delimiter, ","]:
361
- break
368
+ while next_c and next_c != rstring_delimiter:
369
+ i += 1
370
+ next_c = self.get_char_at(i)
362
371
  i += 1
363
372
  next_c = self.get_char_at(i)
373
+ while next_c and next_c != ":":
374
+ if next_c in [
375
+ lstring_delimiter,
376
+ rstring_delimiter,
377
+ ",",
378
+ ]:
379
+ break
380
+ i += 1
381
+ next_c = self.get_char_at(i)
364
382
  # Only if we fail to find a ':' then we know this is misplaced quote
365
383
  if next_c != ":":
366
384
  self.log(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.19.2
3
+ Version: 0.20.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
@@ -0,0 +1,7 @@
1
+ json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
+ json_repair/json_repair.py,sha256=zYg4tIwZ4rdVkCQ5XVceNQaOz2MT50O7jHJbJ1EpKhk,25446
3
+ json_repair-0.20.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
+ json_repair-0.20.0.dist-info/METADATA,sha256=2WrsjORPx37e4CqdkdiARwB-VoP5EyjsZaS0hcVnVBo,7333
5
+ json_repair-0.20.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ json_repair-0.20.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
+ json_repair-0.20.0.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
2
- json_repair/json_repair.py,sha256=qNkCy5by3jFhCAC3pDNKzDECOJr1Crh-P71j6N1CBBg,24405
3
- json_repair-0.19.2.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
- json_repair-0.19.2.dist-info/METADATA,sha256=UdTpknO6GMk16WlPV-YxSFd_QbY25WiNkqj2IE3B_NA,7333
5
- json_repair-0.19.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- json_repair-0.19.2.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
- json_repair-0.19.2.dist-info/RECORD,,