File size: 1,300 Bytes
828fac4
1
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: json_component"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio numpy "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import numpy as np\n", "\n", "with gr.Blocks() as demo:\n", "    inp = gr.JSON(\n", "        label=\"InputJSON\",\n", "        value={\n", "            \"Key 1\": \"Value 1\",\n", "            \"Key 2\": {\"Key 3\": \"Value 2\", \"Key 4\": \"Value 3\"},\n", "            \"Key 5\": [\"Item 1\", \"Item 2\", \"Item 3\"],\n", "            \"Key 6\": 123,\n", "            \"Key 7\": 123.456,\n", "            \"Key 8\": True,\n", "            \"Key 9\": False,\n", "            \"Key 10\": None,\n", "            \"Key 11\": np.array([1, 2, 3]),\n", "        }\n", "    )\n", "    out = gr.JSON(label=\"OutputJSON\")\n", "    btn = gr.Button(\"Submit\")\n", "    btn.click(lambda x: x, inp, out)\n", "\n", "if __name__ == \"__main__\":\n", "    demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}