| Function signature[source] | |
|---|---|
st.json(body, *, expanded=True, width="stretch") | |
| Parameters | |
body (object or str) | The object to print as JSON. All referenced objects should be serializable to JSON as well. If object is a string, we assume it contains serialized JSON. |
expanded (bool or int) | The initial expansion state of the JSON element. This can be one of the following:
Regardless of the initial expansion state, users can collapse or expand any key-value pair to show or hide any part of the object. |
width ("stretch" or int) | The width of the JSON element. This can be one of the following:
|
Examples
import streamlit as st
st.json(
{
"foo": "bar",
"stuff": [
"stuff 1",
"stuff 2",
"stuff 3",
],
"level1": {"level2": {"level3": {"a": "b"}}},
},
expanded=2,
)
Tip
Want a new st.json feature or found a bug? Browse open issues and react with a 👍 on the initial post of the ones that matter to you. Your votes help us prioritize what to work on next.
Still have questions?
Our forums are full of helpful information and Streamlit experts.