rich.json

class rich.json.JSON(json: str, indent: int = 2, highlight: bool = True)[source]

A renderable which pretty prints JSON.

Parameters
  • json (str) – JSON encoded data.

  • indent (int, optional) – Number of characters to indent by. Defaults to True.

  • highlight (bool, optional) – Enable highlighting. Defaults to 2.

classmethod from_data(data: Any, indent: int = 2, highlight: bool = True) rich.json.JSON[source]

Encodes a JSON object from arbitrary data.

Returns

data (Any): An object that may be encoded in to JSON indent (int, optional): Number of characters to indent by. Defaults to 2. highlight (bool, optional): Enable highlighting. Defaults to True.

Return type

Args