Getting data back as list of dictionaries when using Streamlit-ace


Hi Community!
I have a streamlit-ace editor in my code for json format. The input for this editor is a list of dictionaries, but when a user makes any changes, it converts to a string. I want it back as a list of dictionaries

Steps to reproduce

Code snippet:

content = st_ace(value=json.dumps(st.session_state.json_, indent=2), language="json", theme="clouds_midnight")
print(type(content), type(st.session_state.json_))

Expected behavior:
I want to receive it back as a list of dictionaries - [{},{},{}], instead I get “[”{},{},{}“]”
The bad part is, inside my json there are other string values, so this list becomes a list of 4 elements, maybe 5…
Like, one string is -
“expectation_type”: “expect_column_values_to_be_in_set”,
“meta”: {},
“kwargs”: {
“value_set”: [
second string is -
third string is -

Actual behavior:
Before making any changes, type for st.session_state.json_ is <class ‘list’>, after running and saving editor content, it’s string.
I just need it back as the format it was in.
Is there any way to do that?
Thanks in advance!

Hi Community!
I was able to get this done by using json.loads(content)

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.