json-repair 0.17.3__py3-none-any.whl → 0.18.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.
- json_repair/json_repair.py +7 -31
- {json_repair-0.17.3.dist-info → json_repair-0.18.0.dist-info}/METADATA +1 -1
- json_repair-0.18.0.dist-info/RECORD +7 -0
- json_repair-0.17.3.dist-info/RECORD +0 -7
- {json_repair-0.17.3.dist-info → json_repair-0.18.0.dist-info}/LICENSE +0 -0
- {json_repair-0.17.3.dist-info → json_repair-0.18.0.dist-info}/WHEEL +0 -0
- {json_repair-0.17.3.dist-info → json_repair-0.18.0.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -380,14 +380,20 @@ class JSONParser:
|
|
380
380
|
def parse_number(self) -> Union[float, int, str]:
|
381
381
|
# <number> is a valid real number expressed in one of a number of given formats
|
382
382
|
number_str = ""
|
383
|
-
number_chars = set("0123456789-.eE
|
383
|
+
number_chars = set("0123456789-.eE/,")
|
384
384
|
char = self.get_char_at()
|
385
385
|
while char and char in number_chars:
|
386
386
|
number_str += char
|
387
387
|
self.index += 1
|
388
388
|
char = self.get_char_at()
|
389
|
+
if len(number_str) > 1 and number_str[-1] in "-eE/,":
|
390
|
+
# The number ends with a non valid character for a number/currency, rolling back one
|
391
|
+
number_str = number_str[:-1]
|
392
|
+
self.index -= 1
|
389
393
|
if number_str:
|
390
394
|
try:
|
395
|
+
if "," in number_str:
|
396
|
+
return str(number_str)
|
391
397
|
if "." in number_str or "e" in number_str or "E" in number_str:
|
392
398
|
return float(number_str)
|
393
399
|
elif number_str == "-":
|
@@ -573,33 +579,3 @@ def from_file(
|
|
573
579
|
fd.close()
|
574
580
|
|
575
581
|
return jsonobj
|
576
|
-
|
577
|
-
|
578
|
-
text = """
|
579
|
-
{
|
580
|
-
|
581
|
-
"Summary": "The customer inquired about the availability of a specific vehicle model and its pricing. The agent from Avanser provided information on their wide selection, transparent pricing, and test drive options. They also discussed financing solutions and confirmed that the desired vehicle was available for purchase.",
|
582
|
-
|
583
|
-
"Brand": "Avanser",
|
584
|
-
"Model": "Corolla",
|
585
|
-
ran a typo in 'model' name, assuming it should be 'Civic',
|
586
|
-
"Primary topic": "Vehicle Availability and Pricing",
|
587
|
-
"Primary topic explanation": "The customer wanted to know if the specific vehicle model was available and its price.",
|
588
|
-
"Secondary topic": "Test Drive Options and Financing Solutions",
|
589
|
-
"Secondary topic explanation": "The agent discussed test drive options, financing solutions, and confirmed availability of the desired vehicle.",
|
590
|
-
"Issue resolution": "Resolved",
|
591
|
-
"Issue resolution explanation": "The customer's inquiry about the vehicle model was addressed by confirming its availability and discussing pricing and additional services."
|
592
|
-
|
593
|
-
}
|
594
|
-
|
595
|
-
Correction: The 'Model' field should be corrected to 'Civic'. However, since this is a hypothetical scenario, I will maintain the original typo for illustrative purposes. If an actual correction were needed, it would look like this:
|
596
|
-
|
597
|
-
"...",
|
598
|
-
"Model": "Corolla",
|
599
|
-
"Model": "Civic",
|
600
|
-
}
|
601
|
-
|
602
|
-
Note: In real-world applications, such corrections should be made to ensure data accuracy and integrity.
|
603
|
-
"""
|
604
|
-
|
605
|
-
print(repair_json(text))
|
@@ -0,0 +1,7 @@
|
|
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,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
|
2
|
-
json_repair/json_repair.py,sha256=Mw4aUxWbzws6P-CmFvlHFFQwPxTG7cDO43F0BVTbSCg,24744
|
3
|
-
json_repair-0.17.3.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
-
json_repair-0.17.3.dist-info/METADATA,sha256=TFO1PgPY-bbEakk7M0uEWvgOMJs-SPxbhtG-qorq0oY,7333
|
5
|
-
json_repair-0.17.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
json_repair-0.17.3.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
-
json_repair-0.17.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|