json-repair 0.17.2__tar.gz → 0.17.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.17.2
3
+ Version: 0.17.3
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
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
  [project]
5
5
  name = "json_repair"
6
- version = "0.17.2"
6
+ version = "0.17.3"
7
7
  license = {file = "LICENSE"}
8
8
  authors = [
9
9
  { name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
@@ -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))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.17.2
3
+ Version: 0.17.3
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
@@ -56,7 +56,7 @@ def test_repair_json():
56
56
  assert repair_json('{"') == '{}'
57
57
  assert repair_json('["') == '[]'
58
58
  assert repair_json("'\"'") == '"\\\""'
59
- assert repair_json("'string\"\n\t\le") == '"string\\\"\\n\\t\\\\le"'
59
+ assert repair_json("{\"key\": 'string\"\n\t\le'") == '{"key": "string\\"\\n\\t\\\\le"}'
60
60
  assert repair_json('{foo: [}') == '{"foo": []}'
61
61
  assert repair_json('''{ "a": "{ b": {} }" }''') == '{"a": "{ b"}'
62
62
  assert repair_json('{"key": "value:value"}') == '{"key": "value:value"}'
File without changes
File without changes
File without changes