import json
import panel as pn
pn.extension()
The JSON
pane allows rendering arbitrary JSON datastructures in a panel. It renders strings containing valid HTML as well as objects with a _repr_html_
method and may define custom CSS styles.
For layout and styling related parameters see the customization user guide.
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 nodesobject
(str or object): JSON string or JSON serializable objecttheme
(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', height=300, width=500)
json
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)