JSON collapse option

Hi,

Would it be possible to make the streamlit.json() function accept a collapse=True argument to collapse values that are objects.

For example:

Show
{
“names” : [“Amber”, “Simone”, “Paul”]
}

As
{
“names”: […]
}

When streamlit.json(body, collapse=True)

Thank you,

Francis

Hi @francisj!

First, welcome to the Streamlit community!!! :star_struck: :tada: :partying_face: :tada: :nerd_face:

This is a good suggestion! I wen’t ahead and made a feature request on GitHub for you, feel free to add anything I might have missed!

Happy Streamlit-ing!
Marisa

Amazing, thank you @Marisa_Smith !

I’ve really been enjoying streamlit so far. Great for prototyping and will soon test on small production use by an internal team.

Cheers!

1 Like

Hey!

Streamlit is great.

I would like to suggest an enhancement to the JSON collapse option.

A very common situation is where you have

{
Header1: {...}
Header2: {...}
...
Header10: {...}
}

Right now expanded=False ==>

{...}

which is less than useful. First step is almost always to expand the first level.

In a situation like this it would be ideal if we could set the default to display level 1, but collapse the sub-dictionaries.

Instead of a simple boolean expanded option, it would be great if we could instead (or in addition) have a ‘levels’ argument. We display upto that level, and collapse anything deeper.