json-repair 0.17.0__py3-none-any.whl → 0.17.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.
- json_repair/json_repair.py +31 -15
- {json_repair-0.17.0.dist-info → json_repair-0.17.1.dist-info}/METADATA +1 -1
- json_repair-0.17.1.dist-info/RECORD +7 -0
- json_repair-0.17.0.dist-info/RECORD +0 -7
- {json_repair-0.17.0.dist-info → json_repair-0.17.1.dist-info}/LICENSE +0 -0
- {json_repair-0.17.0.dist-info → json_repair-0.17.1.dist-info}/WHEEL +0 -0
- {json_repair-0.17.0.dist-info → json_repair-0.17.1.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -227,6 +227,10 @@ class JSONParser:
|
|
227
227
|
self.index += 1
|
228
228
|
char = self.get_char_at()
|
229
229
|
|
230
|
+
if not char:
|
231
|
+
# This is an empty string
|
232
|
+
return ""
|
233
|
+
|
230
234
|
# Ensuring we use the right delimiter
|
231
235
|
if char == "'":
|
232
236
|
lstring_delimiter = rstring_delimiter = "'"
|
@@ -431,28 +435,40 @@ class JSONParser:
|
|
431
435
|
return ""
|
432
436
|
|
433
437
|
def get_char_at(self, count: int = 0) -> Union[str, bool]:
|
434
|
-
if
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
return
|
444
|
-
|
438
|
+
# Why not use something simpler? Because try/except in python is a faster alternative to an "if" statement that is often True
|
439
|
+
try:
|
440
|
+
return self.json_str[self.index + count]
|
441
|
+
except IndexError:
|
442
|
+
if self.json_fd:
|
443
|
+
self.json_fd.seek(self.index + count)
|
444
|
+
char = self.json_fd.read(1)
|
445
|
+
if char == "":
|
446
|
+
return False
|
447
|
+
return char
|
448
|
+
else:
|
445
449
|
return False
|
446
450
|
|
447
451
|
def skip_whitespaces_at(self) -> None:
|
448
452
|
"""
|
449
453
|
This function quickly iterates on whitespaces, syntactic sugar to make the code more concise
|
450
454
|
"""
|
451
|
-
|
452
|
-
char = self.get_char_at()
|
453
|
-
while char and char.isspace():
|
454
|
-
self.index += 1
|
455
|
+
if self.json_fd:
|
455
456
|
char = self.get_char_at()
|
457
|
+
while char and char.isspace():
|
458
|
+
self.index += 1
|
459
|
+
char = self.get_char_at()
|
460
|
+
else:
|
461
|
+
# If this is not a file stream, we do this monster here to make this function much much faster
|
462
|
+
try:
|
463
|
+
char = self.json_str[self.index]
|
464
|
+
except IndexError:
|
465
|
+
return
|
466
|
+
while char.isspace():
|
467
|
+
self.index += 1
|
468
|
+
try:
|
469
|
+
char = self.json_str[self.index]
|
470
|
+
except IndexError:
|
471
|
+
return
|
456
472
|
|
457
473
|
def set_context(self, value: str) -> None:
|
458
474
|
# If a value is provided update the context variable and save in stack
|
@@ -0,0 +1,7 @@
|
|
1
|
+
json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
|
2
|
+
json_repair/json_repair.py,sha256=STzwcsoAV8jB1hXQXKs9vYMhemV22vCiH14jyVG4v4A,23311
|
3
|
+
json_repair-0.17.1.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
+
json_repair-0.17.1.dist-info/METADATA,sha256=LdjjpdQsJ1WuyQ28Z36cvDfMJE91lO4iHV2NhQ_RqNc,7355
|
5
|
+
json_repair-0.17.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
json_repair-0.17.1.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
+
json_repair-0.17.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=BeThFqLxt2-ln7SA3UPBI47VyxnV2MVDFEaolIOCiNU,22721
|
3
|
-
json_repair-0.17.0.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
-
json_repair-0.17.0.dist-info/METADATA,sha256=F2KOc46utpaJg3eqlw8oaWhisj3rDnHk-k-5miiWL3U,7355
|
5
|
-
json_repair-0.17.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
json_repair-0.17.0.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
-
json_repair-0.17.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|