gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.73k stars 2.29k forks source link

List objects not being displayed properly in gr.json() objects #8373

Closed mberco-quandl closed 1 month ago

mberco-quandl commented 1 month ago

Describe the bug

When returning a python list to a gr.json() object it does not properly format it. See how it introduces a pseudo key-value appearing structure within the square bracers of the list. Peculiarly, when one clicks the "Copy" button on the gr.json() object, properly formatted json is copied as shown below! It appears to be solely a visual artefact.

[
  {
    "match_ordinal": "1",
    "match_score": "99",
    "org_name": "JP Morgan Securities plc (Frankfurt am Main Branch)",
    "org_perm_id": "5001223099",
    "uuid": "1"
  }
]

Have you searched existing issues? 🔎

Reproduction

import gradio as gr
with gr.Blocks() as demo:
    text_output = gr.Text()
    json_output = gr.JSON()

    def return_list():
        my_list = [{"some": "data"}]
        return my_list, my_list

   demo.load(return_list, inputs=None, outputs=[text_output, json_output])

Screenshot

image

Logs

no errors.

System Info

gradio=4.27.0

Severity

I can work around it

abidlabs commented 1 month ago

Yes agreed we should fix this, we’ve heard this reported before I believe

abidlabs commented 1 month ago

Here's the duplicate: https://github.com/gradio-app/gradio/issues/6949 so let me close this one