diff --git a/rich/console.py b/rich/console.py index 6edd7c8af..8abc382fe 100644 --- a/rich/console.py +++ b/rich/console.py @@ -1668,7 +1668,17 @@ def print_json( raise TypeError( f"json must be str. Did you mean print_json(data={json!r}) ?" ) - json_renderable = JSON(json, indent=indent, highlight=highlight) + json_renderable = JSON( + json, + indent=indent, + highlight=highlight, + skip_keys=skip_keys, + ensure_ascii=ensure_ascii, + check_circular=check_circular, + allow_nan=allow_nan, + default=default, + sort_keys=sort_keys, + ) self.print(json_renderable) def update_screen( diff --git a/tests/test_console.py b/tests/test_console.py index 202ad0a55..6660ec9d1 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -141,6 +141,15 @@ def test_print_json_data(): assert result == expected +def test_print_json_ensure_ascii(): + console = Console(file=io.StringIO(), color_system="truecolor") + console.print_json(data={"foo": "💩"}, ensure_ascii=False) + result = console.file.getvalue() + print(repr(result)) + expected = '\x1b[1m{\x1b[0m\n \x1b[1;34m"foo"\x1b[0m: \x1b[32m"💩"\x1b[0m\n\x1b[1m}\x1b[0m\n' + assert result == expected + + def test_log(): console = Console( file=io.StringIO(),