Processing of JSON strings inside a JSON object
In Make, JSON-based APIs are natively supported. Nevertheless, some APIs may have a JSON string inside a JSON object.
If such API returns a JSON string inside a JSON object, the data inside a JSON string is treated as text and the child parameters cannot be directly mapped.
On the contrary, if the API requires a parameter in JSON string format, Make has to send it in the required format.
{
"address": "{\"zip\":\"18000\",\"city\":\"Prague\",\"state\":\"Czechia\",\"country\":\"Czechia\",\"address1\":\"Menclova 2\"}",
"id": "123",
"name": "Make Office"
}
Creating a JSON String
If the API requires a parameter to be sent as a JSON string, the createJSON()
function can be used.
{
...
"body": {
"{{...}}": "{{omit(parameters, 'address')}}",
"address": "{{createJSON(parameters.address)}}"
},
...
}
Parsing a JSON String
If the API output contains a parameter in a JSON string format, the parseJSON()
function can be used.
{
...
"output": {
"{{...}}": "{{omit(body, 'address')}}",
"address": "{{parseJSON(body.address)}}"
},
...
}
Last updated