json-repair 0.1.4__py3-none-any.whl → 0.1.6__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.
@@ -46,7 +46,9 @@ class JSONParser:
46
46
  if self.get_char_at() != ":":
47
47
  self.insert_char_at(":")
48
48
  self.index += 1
49
+ self.context = "object_value"
49
50
  value = self.parse_json()
51
+ self.context = ""
50
52
  obj[key] = value
51
53
 
52
54
  if self.get_char_at() == ",":
@@ -95,6 +97,7 @@ class JSONParser:
95
97
  (char := self.get_char_at()) != '"'
96
98
  and char is not False
97
99
  and (self.context != "object_key" or char != ":")
100
+ and (self.context != "object_value" or (char != "," and char != "}"))
98
101
  ):
99
102
  self.index += 1
100
103
 
@@ -102,7 +105,7 @@ class JSONParser:
102
105
  if self.get_char_at() != '"':
103
106
  self.insert_char_at('"')
104
107
  # A fallout of the previous special case, we need to update the index only if we didn't enter that case
105
- if self.context != "object_key" or char != ":":
108
+ if (self.context != "object_key" or char != ":") and (self.context != "object_value" or (char != "," and char != "}")):
106
109
  self.index += 1
107
110
 
108
111
  return self.json_str[start:end]
@@ -153,5 +156,3 @@ def repair_json(json_str: str, return_objects: bool = False) -> any:
153
156
  if return_objects:
154
157
  return parsed_json
155
158
  return json.dumps(parsed_json)
156
-
157
- print(repair_json('{"name": "John", "age": 30, "city": New York}'))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json-repair
3
- Version: 0.1.4
3
+ Version: 0.1.6
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=5Sn_TG7QYURJ6Fo9s7-vzngauLjfLQ1FVDgmZ35oS1c,52
2
+ json_repair/json_repair.py,sha256=MbP2LWsfJmB7KoeV3Q5Pqvi9r05kRsGOfCdrhXXF6EM,5138
3
+ json_repair-0.1.6.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
+ json_repair-0.1.6.dist-info/METADATA,sha256=8X5GeJ-btfCFKp-6Ycq1rUHJa9X1pnNScz3VvjrXdVg,3482
5
+ json_repair-0.1.6.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
6
+ json_repair-0.1.6.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
+ json_repair-0.1.6.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- json_repair/__init__.py,sha256=5Sn_TG7QYURJ6Fo9s7-vzngauLjfLQ1FVDgmZ35oS1c,52
2
- json_repair/json_repair.py,sha256=VGN5pHXCxxbPW9ZWwhsBL9GlNB9TVcI42cGRpCCJor4,4980
3
- json_repair-0.1.4.dist-info/LICENSE,sha256=wrjQo8MhNrNCicXtMe3MHmS-fx8AmQk1ue8AQwiiFV8,1076
4
- json_repair-0.1.4.dist-info/METADATA,sha256=OIGMlfakI_swwW8p3OWjK4xg5O1n7_4DyYL8Gcg6GzM,3482
5
- json_repair-0.1.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
6
- json_repair-0.1.4.dist-info/top_level.txt,sha256=7-VZwZN2CgB_n0NlSLk-rEUFh8ug21lESbsblOYuZqw,12
7
- json_repair-0.1.4.dist-info/RECORD,,