Editable gr.JSON component #10156
Labels
enhancement
New feature or request
needs designing
The proposed feature needs to be discussed and designed before being implemented
Is your feature request related to a problem? Please describe.
I frequently use the
gr.JSON
component to display data dictionaries and JSON (as text). However, the component does not allow editing the dictionary that the component displays. The capability to edit may be desirable in some use-cases.For example, while a
gr.Dataframe
component can render a Polars data frame and even allows it to be edited, the Polars dataframe may contain the data typeStruct
. This type of data is best rendered through thegr.JSON
component, when viewed per row. Editing the Polars data frame then necessitates editing the rendered JSON for columns that Polars parses asStruct
.Describe the solution you'd like
I do not have a well thought out solution to this. I think one clear problem will be data validation.
One solution (to data validation) could be to detect the data type of every dictionary key and and its corresponding value (excluding nested tuples, lists and dictionaries) and typecast the newly edited data to the detected data type. On the other hand, if the dictionary being displayed is the output (i.e.,
model_dump
) of a Pydantic model then use the Pydantic validator to depend on any complex validation that needs to take place on the edited data.Additional context
Check the "Dataset" tab at https://huggingface.co/spaces/anirbanbasu/gradio-experiments. Try to upload some data as CSV, JSON or Parquet to render it as a Polars dataframe. Click any row of the displayed data frame to see the row rendered as JSON. he The ability to edit the data through the JSON component ensures that it can still be edited even if columns of the data frame are not simple types.
The text was updated successfully, but these errors were encountered: