json-repair 0.15.3__tar.gz → 0.15.5__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.15.3
3
+ Version: 0.15.5
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.15.3"
6
+ version = "0.15.5"
7
7
  license = {file = "LICENSE"}
8
8
  authors = [
9
9
  { name="Stefano Baccianella", email="4247706+mangiucugna@users.noreply.github.com" },
@@ -226,10 +226,20 @@ class JSONParser:
226
226
  lstring_delimiter = rstring_delimiter = string_quotes
227
227
  # There is sometimes a weird case of doubled quotes, we manage this also later in the while loop
228
228
  if self.get_char_at(1) == lstring_delimiter:
229
- self.log(
230
- "While parsing a string, we found a doubled quote, ignoring it", "info"
231
- )
232
- self.index += 1
229
+ # This is a valid exception only if it's closed by a double delimiter again
230
+ i = 2
231
+ next_c = self.get_char_at(i)
232
+ while next_c and next_c != rstring_delimiter:
233
+ i += 1
234
+ next_c = self.get_char_at(i)
235
+ # Now check that the next character is also a delimiter to ensure that we have "".....""
236
+ # In that case we ignore this rstring delimiter
237
+ if next_c and (self.get_char_at(i + 1) or "") == rstring_delimiter:
238
+ self.log(
239
+ "While parsing a string, we found a valid starting doubled quote, ignoring it",
240
+ "info",
241
+ )
242
+ self.index += 1
233
243
  char = self.get_char_at()
234
244
  if char != lstring_delimiter:
235
245
  self.log(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: json_repair
3
- Version: 0.15.3
3
+ Version: 0.15.5
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
@@ -107,11 +107,11 @@ def test_repair_json():
107
107
  assert repair_json('{"key\_1\n": "value"}') == '{"key_1": "value"}'
108
108
  assert repair_json('{"key\t\_": "value"}') == '{"key\\t_": "value"}'
109
109
  assert repair_json('{""answer"":[{""traits"":''Female aged 60+'',""answer1"":""5""}]}') == '{"answer": [{"traits": "Female aged 60+", "answer1": "5"}]}'
110
- assert repair_json('{""answer":[{""traits":""Female aged 60+",""answer1":""5"}]}') == '{"answer": [{"traits": "Female aged 60+", "answer1": "5"}]}'
111
- assert repair_json('{"key":"",}') == '{"key": ",}"}'
110
+ assert repair_json('{"key":""') == '{"key": ""}'
112
111
  assert repair_json('{ "words": abcdef", "numbers": 12345", "words2": ghijkl" }') == '{"words": "abcdef", "numbers": 12345, "words2": "ghijkl"}'
113
112
  assert repair_json('{"key": 1/3}') == '{"key": "1/3"}'
114
113
  assert repair_json('{"key": .25}') == '{"key": 0.25}'
114
+ assert repair_json("""{ "a": "", "b": [ { "c": 1} ] \n}```""") == '{"a": "", "b": [{"c": 1}]}'
115
115
 
116
116
 
117
117
  def test_repair_json_with_objects():
File without changes
File without changes
File without changes