Skip to content

Json Type value can not show in Example component #10801

@hiwei93

Description

@hiwei93

Describe the bug

The app contains a gr.JSON component, for which I intend to provide examples using gr.Examples. However, gr.Examples fails to display the JSON value.

No errors are raised, but the component simply does not show any content.

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

def get_examples():
    return [
        ["aabc", None, '{"a": 1, "b": 2}'],  # this will not display
        ["2134", None, {"c": 3, "d": 4}],  # this will not display
        ["abfgj", None, None], # this will not display too
     ]


with gr.Blocks() as demo:
    text = gr.Textbox()
    video = gr.Video()
    vinfo = gr.JSON('{"a": 1, "b": 2}')
    gr.Examples(
        get_examples(),
        inputs=[text, video, vinfo],
    )
demo().launch(
        debug=True,
)

Screenshot

Image

Logs

System Info

Gradio Environment Information:
------------------------------
Operating System: Darwin
gradio version: 5.20.0
gradio_client version: 1.7.2

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 4.3.0
audioop-lts is not installed.
fastapi: 0.115.11
ffmpy: 0.3.2
gradio-client==1.7.2 is not installed.
groovy: 0.1.2
httpx: 0.27.0
huggingface-hub: 0.29.2
jinja2: 3.1.3
markupsafe: 2.1.5
numpy: 1.26.4
orjson: 3.10.1
packaging: 24.0
pandas: 2.2.2
pillow: 10.3.0
pydantic: 2.7.0
pydub: 0.25.1
python-multipart: 0.0.20
pyyaml: 6.0.1
ruff: 0.9.9
safehttpx: 0.1.6
semantic-version: 2.10.0
starlette: 0.46.0
tomlkit: 0.12.0
typer: 0.12.3
typing-extensions: 4.11.0
urllib3: 2.2.1
uvicorn: 0.29.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2024.3.1
httpx: 0.27.0
huggingface-hub: 0.29.2
packaging: 24.0
typing-extensions: 4.11.0
websockets: 11.0.3

Severity

Blocking usage of gradio

Metadata

Metadata

Labels

PriorityHigh priority issuesbugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions