Write JSON

Hi, I like the JSON object, and I’m wondering if it is possible to access JS properties of the widget during runtime.

Especially for larger JSON objects it would be good to influence the output props.
see (GitHub - mac-s-g/react-json-view: JSON viewer for react)

for instance
collapsed can be boolean or integer and is by default false.
You could also use an integer value to collapse at a particular depth.

Is there a good practice to customize such a streamalit/JSON element?

Hi @mauermbq -

There aren’t any ways to access it as far as I know, as the st.write function doesn’t return information. This could be an area for a bi-directional Streamlit component, if the React library you’re linking to is dramatically better or you have a really novel use-case.

Best,
Randy

Thank you randy!

I’m referring to streamlit.json( *body* ) - display component

I checked this in the streamlit git repo, and the author of this uses the react-json-view. I’m wondering if I can set some of the JS Properties during runtime.
br
Mark

1 Like

Thanks for clarifying. I think this is an area where if you made an enhancement proposal on GitHub and make a PR (if you can), adding keyword arguments to the function would be well-received.

done: adding keyword arguments to streamlit.json(body) · Issue #2816 · streamlit/streamlit · GitHub

2 Likes

I endorse this. It would be immediately useful to me as I have many archives of blog, etc. data in json format. I would like to be able to provide users with custom filters that highlight, e.g., only post & author key/value pairs.