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.
JSON String Occurence in a module
Copy {
"address": "{\"zip\":\"18000\",\"city\":\"Prague\",\"state\":\"Czechia\",\"country\":\"Czechia\",\"address1\":\"Menclova 2\"}",
"id": "123",
"name": "Make Office"
}
Notice the address
parameter that has value in JSON string format.
Notice the address
parameter. Since the parameter is a JSON string, the content is not parsed as a collection.
Communication Request body
Copy {
...
"body": {
"{{...}}": "{{omit(parameters, 'address')}}",
"address": "{{createJSON(parameters.address)}}"
},
...
}
Notice that the createJSON()
function is used to format the address
value to a JSON string.
Copy {
"address": "{\"zip\":\"18000\",\"city\":\"Prague\",\"state\":\"Czechia\",\"country\":\"Czechia\",\"address1\":\"Menclova 2\"}",
"id": "123",
"name": "Make Office"
}
Notice that the address
parameter is sent in JSON string format.
Communication Raw response body Parsed response body
Copy {
...
"output": {
"{{...}}": "{{omit(body, 'address')}}",
"address": "{{parseJSON(body.address)}}"
},
...
}
Notice that the parseJSON()
function is used to parse the address
value to JSON .
Copy {
"address": "{\"zip\":\"18000\",\"city\":\"Prague\",\"state\":\"Czechia\",\"country\":\"Czechia\",\"address1\":\"Menclova 2\"}",
"id": "123",
"name": "Make Office"
}
If the parseJSON()
function is not used, the JSON string is returned in a raw format.
Copy [
{
"address": {
"zip": "18000",
"city": "Prague",
"state": "Czechia",
"country": "Czechia",
"address1": "Menclova 2"
},
"id": "123",
"name": "Make Office"
}
]
If the parseJSON()
function is used, the value in address
parameter is parsed to JSON . The address
parameter is returned as a collection.