Method: rich.print_json
Calls: 3, Exceptions: 0, Paths: 1Back
Path 1: 3 calls (1.0)
'[false, true, null, "foo"]' (1) None (1) '["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 20...
None (2) ['xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 2e+128] (1)
4 (3)
True (3)
False (3)
False (3)
True (3)
True (3)
None (3)
False (3)
1def print_json(
2 json: Optional[str] = None,
3 *,
4 data: Any = None,
5 indent: Union[None, int, str] = 2,
6 highlight: bool = True,
7 skip_keys: bool = False,
8 ensure_ascii: bool = False,
9 check_circular: bool = True,
10 allow_nan: bool = True,
11 default: Optional[Callable[[Any], Any]] = None,
12 sort_keys: bool = False,
13) -> None:
14 """Pretty prints JSON. Output will be valid JSON.
15
16 Args:
17 json (str): A string containing JSON.
18 data (Any): If json is not supplied, then encode this data.
19 indent (int, optional): Number of spaces to indent. Defaults to 2.
20 highlight (bool, optional): Enable highlighting of output: Defaults to True.
21 skip_keys (bool, optional): Skip keys not of a basic type. Defaults to False.
22 ensure_ascii (bool, optional): Escape all non-ascii characters. Defaults to False.
23 check_circular (bool, optional): Check for circular references. Defaults to True.
24 allow_nan (bool, optional): Allow NaN and Infinity values. Defaults to True.
25 default (Callable, optional): A callable that converts values that can not be encoded
26 in to something that can be JSON encoded. Defaults to None.
27 sort_keys (bool, optional): Sort dictionary keys. Defaults to False.
28 """
29
30 get_console().print_json(
31 json,
32 data=data,
33 indent=indent,
34 highlight=highlight,
35 skip_keys=skip_keys,
36 ensure_ascii=ensure_ascii,
37 check_circular=check_circular,
38 allow_nan=allow_nan,
39 default=default,
40 sort_keys=sort_keys,
41 )