json_test / app.py
hmb's picture
hmb HF staff
Create app.py
eaa50e0 verified
raw
history blame contribute delete
No virus
823 Bytes
import gradio as gr
import json
JSONOBJ = """{"items":{"item":[{"id": "0001","type": null,"is_good": false,"ppu": 0.55,"batters":{"batter":[{ "id": "1001", "type": "Regular" },{ "id": "1002", "type": "Chocolate" },{ "id": "1003", "type": "Blueberry" },{ "id": "1004", "type": "Devil's Food" }]},"topping":[{ "id": "5001", "type": "None" },{ "id": "5002", "type": "Glazed" },{ "id": "5005", "type": "Sugar" },{ "id": "5007", "type": "Powdered Sugar" },{ "id": "5006", "type": "Chocolate with Sprinkles" },{ "id": "5003", "type": "Chocolate" },{ "id": "5004", "type": "Maple" }]}]}}"""
def fn(inp):
return json.loads(JSONOBJ)
with gr.Blocks() as demo:
out = gr.JSON(label="OutputJSON")
btn = gr.Button(value="submit")
btn.click(fn, inputs=out, outputs=out)
if __name__ == "__main__":
demo.launch()