Skip to content

Commit

Permalink
Fix #55, a regression from previous features in which string not sepa…
Browse files Browse the repository at this point in the history
…rated by commas in array were handled poorly
  • Loading branch information
mangiucugna committed Jun 27, 2024
1 parent ba0a992 commit e55313f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
[project]
name = "json_repair"
version = "0.25.1"
version = "0.25.2"
license = {file = "LICENSE"}
authors = [
{ name="Stefano Baccianella", email="[email protected]" },
Expand Down
18 changes: 9 additions & 9 deletions src/json_repair/json_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,15 @@ def parse_string(self) -> Union[str, JSONReturnType]:
break
i += 1
next_c = self.get_char_at(i)
# Only if we fail to find a ':' then we know this is misplaced quote
if next_c != ":":
self.log(
"While parsing a string, we a misplaced quote that would have closed the string but has a different meaning here, ignoring it",
"info",
)
string_acc += char
self.index += 1
char = self.get_char_at()
# Only if we fail to find a ':' then we know this is misplaced quote
if next_c != ":":
self.log(
"While parsing a string, we a misplaced quote that would have closed the string but has a different meaning here, ignoring it",
"info",
)
string_acc += char
self.index += 1
char = self.get_char_at()

if (
char
Expand Down
1 change: 1 addition & 0 deletions tests/test_json_repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def test_array_edge_cases():
assert repair_json("[1, 2, ... , 3]") == "[1, 2, 3]"
assert repair_json("[1, 2, '...', 3]") == '[1, 2, "...", 3]'
assert repair_json("[true, false, null, ...]") == '[true, false, null]'
assert repair_json('["a" "b" "c" 1') == '["a", "b", "c", 1]'
assert (
repair_json('{"employees":["John", "Anna",')
== '{"employees": ["John", "Anna"]}'
Expand Down

0 comments on commit e55313f

Please sign in to comment.