json-repair 0.17.2__py3-none-any.whl → 0.17.3__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 +33 -1
- {json_repair-0.17.2.dist-info → json_repair-0.17.3.dist-info}/METADATA +1 -1
- json_repair-0.17.3.dist-info/RECORD +7 -0
- json_repair-0.17.2.dist-info/RECORD +0 -7
- {json_repair-0.17.2.dist-info → json_repair-0.17.3.dist-info}/LICENSE +0 -0
- {json_repair-0.17.2.dist-info → json_repair-0.17.3.dist-info}/WHEEL +0 -0
- {json_repair-0.17.2.dist-info → json_repair-0.17.3.dist-info}/top_level.txt +0 -0
json_repair/json_repair.py
CHANGED
@@ -113,6 +113,7 @@ class JSONParser:
|
|
113
113
|
# <member> starts with a <string>
|
114
114
|
key = ""
|
115
115
|
while key == "" and self.get_char_at():
|
116
|
+
current_index = self.index
|
116
117
|
key = self.parse_string()
|
117
118
|
|
118
119
|
# This can happen sometimes like { "": "value" }
|
@@ -123,7 +124,8 @@ class JSONParser:
|
|
123
124
|
"info",
|
124
125
|
)
|
125
126
|
break
|
126
|
-
elif key == "":
|
127
|
+
elif key == "" and self.index == current_index:
|
128
|
+
# Sometimes the string search might not move the index at all, that might lead us to an infinite loop
|
127
129
|
self.index += 1
|
128
130
|
|
129
131
|
# We reached the end here
|
@@ -571,3 +573,33 @@ def from_file(
|
|
571
573
|
fd.close()
|
572
574
|
|
573
575
|
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=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,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
json_repair/__init__.py,sha256=IIzSm1DsCRrr8seF3UeMZXwxcq-tE3j-8d1WBxvEJvE,178
|
2
|
-
json_repair/json_repair.py,sha256=NeAKskIWOewTpIDY3Z6wxYkDHjrNYHNuF4AFO-xBggI,23052
|
3
|
-
json_repair-0.17.2.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
|
4
|
-
json_repair-0.17.2.dist-info/METADATA,sha256=5YoWE0n-iKY2nbZ0D9OQ8QwfA6zZIYVWUkLsYQmxrqo,7333
|
5
|
-
json_repair-0.17.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
json_repair-0.17.2.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
|
7
|
-
json_repair-0.17.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|