Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ then you can use use it in your code like this
good_json_string = repair_json(bad_json_string)
# If the string was super broken this will return an empty string


You can use this library to completely replace `json.loads()`:

import json_repair
Expand Down
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.45.0"
version = "0.45.1"
license = {file = "LICENSE"}
authors = [
{ name="Stefano Baccianella", email="[email protected]" },
Expand Down
5 changes: 5 additions & 0 deletions src/json_repair/json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,11 @@ def parse_comment(self) -> str:
break
self.log(f"Found block comment: {comment}")
return ""
else:
# Skip standalone '/' characters that are not part of a comment
# to avoid getting stuck in an infinite loop
self.index += 1
return ""
return "" # pragma: no cover

def get_char_at(self, count: int = 0) -> str | Literal[False]:
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 @@ -83,6 +83,7 @@ def test_general_edge_cases():
assert repair_json("[[1\n\n]") == "[[1]]"
assert repair_json("string") == ""
assert repair_json("stringbeforeobject {}") == "{}"
assert repair_json("/") == ""


def test_mixed_data_types():
Expand Down
Loading