MCPcopy
hub / github.com/Textualize/rich / print_json

Function print_json

rich/__init__.py:77–117  ·  view source on GitHub ↗

Pretty prints JSON. Output will be valid JSON. Args: json (str): A string containing JSON. data (Any): If json is not supplied, then encode this data. indent (int, optional): Number of spaces to indent. Defaults to 2. highlight (bool, optional): Enable highlighti

(
    json: Optional[str] = None,
    *,
    data: Any = None,
    indent: Union[None, int, str] = 2,
    highlight: bool = True,
    skip_keys: bool = False,
    ensure_ascii: bool = False,
    check_circular: bool = True,
    allow_nan: bool = True,
    default: Optional[Callable[[Any], Any]] = None,
    sort_keys: bool = False,
)

Source from the content-addressed store, hash-verified

75
76
77def print_json(
78 json: Optional[str] = None,
79 *,
80 data: Any = None,
81 indent: Union[None, int, str] = 2,
82 highlight: bool = True,
83 skip_keys: bool = False,
84 ensure_ascii: bool = False,
85 check_circular: bool = True,
86 allow_nan: bool = True,
87 default: Optional[Callable[[Any], Any]] = None,
88 sort_keys: bool = False,
89) -> None:
90 """Pretty prints JSON. Output will be valid JSON.
91
92 Args:
93 json (str): A string containing JSON.
94 data (Any): If json is not supplied, then encode this data.
95 indent (int, optional): Number of spaces to indent. Defaults to 2.
96 highlight (bool, optional): Enable highlighting of output: Defaults to True.
97 skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
98 ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
99 check_circular (bool, optional): Check for circular references. Defaults to True.
100 allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
101 default (Callable, optional): A callable that converts values that can not be encoded
102 in to something that can be JSON encoded. Defaults to None.
103 sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
104 """
105
106 get_console().print_json(
107 json,
108 data=data,
109 indent=indent,
110 highlight=highlight,
111 skip_keys=skip_keys,
112 ensure_ascii=ensure_ascii,
113 check_circular=check_circular,
114 allow_nan=allow_nan,
115 default=default,
116 sort_keys=sort_keys,
117 )
118
119
120def inspect(

Callers

nothing calls this directly

Calls 2

get_consoleFunction · 0.85
print_jsonMethod · 0.80

Tested by

no test coverage detected