Build json with values from controls

I have a legacy service that use APIRest and the POST method receive a JSON body.

So, on retool app the user add data in different settings controls (isn’t a form) and this element need add in a preset JSON.

I tried use a variable temporary state to build the complete JSON using an initial state [] and use push for adding new elements, but not work.

Any recommendation for building JSON element in runtime?

This is how I've used the query builder in the past for this type of request. Two different examples below.

When you import the query into an app you will use the vars to fill in the json.

Nice, but is possible build and array inside the json?
Adding one to one element using push o similar.

"countries": [
        "proper1": "string",
        "proper2": 0,
        "images": [
            "type": "string",
            "url": "string"
            "type": "string",
            "url": "string"

There are probably several different ways to do this and I'm still a bit unsure what your app looks like. Here are a couple options that I've used in the past.

You could use a js query, which upon trigger

  • builds the array locally (query local scope) from various components within your app and triggers another query (the rest query) using additionalScope
  • builds the array and stores it in temporary state (global in your app until the app is reset) for later use when triggering the rest query

A couple links you might want to check out