Skip to content

Commit

Permalink
Fix #72, when checking for closing string_delimeters, ignore the esca…
Browse files Browse the repository at this point in the history
…ped ones.
  • Loading branch information
mangiucugna committed Sep 26, 2024
1 parent bdbea5f commit efe3f4b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/json_repair/json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ def parse_string(self) -> Union[str, bool, None]:
rstring_delimiter_missing = True
# check if this is a case in which the closing comma is NOT missing instead
i = self.skip_to_character(character=rstring_delimiter, idx=1)
# If the rstring_delimeter is escaped then it's not what we are looking for
while self.get_char_at(i - 1) == "\\":
i = self.skip_to_character(character=rstring_delimiter, idx=i + 1)
next_c = self.get_char_at(i)
if next_c:
i += 1
Expand Down Expand Up @@ -411,6 +414,11 @@ def parse_string(self) -> Union[str, bool, None]:
):
i += 1
i = self.skip_to_character(character=rstring_delimiter, idx=i)
# If the rstring_delimeter is escaped then it's not what we are looking for
while self.get_char_at(i - 1) == "\\":
i = self.skip_to_character(
character=rstring_delimiter, idx=i + 1
)
next_c = self.get_char_at(i)
# Ok now I found a delimiter, let's skip whitespaces and see if next we find a }
i += 1
Expand All @@ -433,6 +441,11 @@ def parse_string(self) -> Union[str, bool, None]:
i = self.skip_to_character(
character=rstring_delimiter, idx=i
)
# If the rstring_delimeter is escaped then it's not what we are looking for
while self.get_char_at(i - 1) == "\\":
i = self.skip_to_character(
character=rstring_delimiter, idx=i + 1
)
i += 1
next_c = self.get_char_at(i)
while next_c and next_c != ":":
Expand Down

0 comments on commit efe3f4b

Please sign in to comment.