JSON#

Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).


import json
import panel as pn

pn.extension()

The JSON pane allows rendering arbitrary JSON strings, dicts and other json serializable objects in a panel.

Parameters:#

For details on other options for customizing the component see the layout and styling how-to guides.

  • depth (int): Depth to which the JSON structure is expanded on initialization (depth=-1 indicates full expansion)

  • hover_preview (bool): Whether to enable hover preview for collapsed nodes

  • object (str or object): JSON string or JSON serializable object

  • theme (string): The color scheme, one of ‘light’ or ‘dark’


The JSON pane can be used to render a tree view of arbitrary JSON objects which may be defined as a string or a JSON-serializable Python object.

json_obj = {
    'boolean': False,
    'dict': {'a': 1, 'b': 2, 'c': 3},
    'int': 1,
    'float': 3.1,
    'list': [1, 2, 3],
    'null': None,
    'string': 'A string',
}

json = pn.pane.JSON(json_obj, name='JSON')

json

Controls#

The JSON pane exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:

pn.Row(json.controls(jslink=True), json)

Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).