Dynamic JSON from user input

New to Retool and would like some help with building a form that will construct an SQL query on submit.

One of the fields should generate a JSON such as:
{"key1": "UserId", "key2": "CreatedAt"}

The number of keys is variable with at least 1 required, so the field should allow the user to add multiple keys (listed key1, key2, key3...).

How should I go about this? Thanks!

Welcome to Retool :tada:

How will the user enable new keys on the form? Will there be a dropdown or some ui for them to pick new key/value pairs to add?

If you choose to use our native form component, you'll want to add all possible child components and then you can show/hide them dynamically based on what the user selects.

Otherwise, you could use our JSON schema form, and you could have a dynamic form schema that changes based on user input (using Javascript inside of double curly brackets {{}})

We have more info about the two options here