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
2 changes: 1 addition & 1 deletion fixit/jsonfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def format_json(raw: str, indent: int = 2) -> str:
"""
try:
data = json.loads(raw)
return json.dumps(data, indent=indent)
return json.dumps(data, indent=indent, ensure_ascii=False)
except json.JSONDecodeError:
raise ValueError("Invalid JSON")
5 changes: 5 additions & 0 deletions tests/test_jsonfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ def test_format_json():
def test_invalid_json_friendly_error():
with pytest.raises(ValueError, match="Invalid JSON"):
format_json("{not json")


def test_format_json_preserves_unicode():
assert format_json('{"name": "café"}') == '{\n "name": "café"\n}'