Template and input as JSON
Maps inputJson onto the shape of templateJson.
Input
{
"templateJson": {
"creationDate": "{{info.created_at}}",
"creator": {
"name": "{{info.created_by}}"
},
"people": [
"{{staff.developers}}",
{
"firstName": "{{name}}",
"city": "{{address.city}}",
"likes": "{{hobbies}}",
"hobbies": "=> join(hobbies,' & ')",
"age": "=> toNumber(age)",
"isAdmin": "=> toBoolean(isAdmin)"
}
]
},
"inputJson": {
"info": {
"created_at": "01.01.2023",
"created_by": "1001fx Admin"
},
"staff": {
"developers": [
{
"name": "Rob",
"address": {
"city": "London"
},
"hobbies": [
"cycling",
"hifi"
],
"age": "22",
"isAdmin": "true"
},
{
"name": "Chris",
"address": {
"city": "Oxford"
},
"hobbies": [
"hill walking"
]
}
]
}
}
}Output · HTTP 200
{
"result": {
"creationDate": "01.01.2023",
"creator": {
"name": "1001fx Admin"
},
"people": [
{
"firstName": "Rob",
"city": "London",
"likes": [
"cycling",
"hifi"
],
"hobbies": "cycling & hifi",
"age": 22,
"isAdmin": true
},
{
"firstName": "Chris",
"city": "Oxford",
"likes": [
"hill walking"
],
"hobbies": "hill walking"
}
]
}
}Show curl command
curl -X POST 'https://api.1001fx.com/data/json2json' \
-H 'X-API-KEY: YOURSECRETAPIKEY' \
-H 'Content-Type: application/json' \
-d '{"templateJson":{"creationDate":"{{info.created_at}}","creator":{"name":"{{info.created_by}}"},"people":["{{staff.developers}}",{"firstName":"{{name}}","city":"{{address.city}}","likes":"{{hobbies}}","hobbies":"=> join(hobbies,'\'' & '\'')","age":"=> toNumber(age)","isAdmin":"=> toBoolean(isAdmin)"}]},"inputJson":{"info":{"created_at":"01.01.2023","created_by":"1001fx Admin"},"staff":{"developers":[{"name":"Rob","address":{"city":"London"},"hobbies":["cycling","hifi"],"age":"22","isAdmin":"true"},{"name":"Chris","address":{"city":"Oxford"},"hobbies":["hill walking"]}]}}}'