This is barking in my change node using JSONata:
[
$map(
payload,
function($v)
[
{
"fieldKey": "fieldUUID",
"value": $v.fieldUUID
},
{
"fieldKey": "fieldName",
"value": $v.fieldName
}
]
)
]
with this error:
Invalid JSONata expression:
Expected "{", got "["
And so is this:
[
$map(
payload,
function($v)
{
{
"fieldKey": "fieldUUID",
"value": $v.fieldUUID
},
{
"fieldKey": "fieldName",
"value": $v.fieldName
}
}
)
]
with this error:
Invalid JSONata expression:
Expected "}", got ","
Both are perfectly valid JSON after the function().
The target API endpoint request body requires the following:
{
"fieldKey": "Fields",
"value": [
[
{
"fieldKey": "fieldUUID",
"value": "8be8e0ff-b7c8-4762-8d2d-36a176d55923"
},
{
"fieldKey": "fieldName",
"value": "Big Muddy"
}
],
[
{
"fieldKey": "fieldUUID",
"value": "aaba874a-8629-4c8b-a410-b1b3bc35c6e8"
},
{
"fieldKey": "fieldName",
"value": "Grandma's"
}
],
[
{
"fieldKey": "fieldUUID",
"value": "ab17ddc4-7726-438b-9bb1-95112a089f02"
},
{
"fieldKey": "fieldName",
"value": "Jefftown Creek"
}
]
]
}
GeoJSON coordinates and a lot of other standard APIs have nested array requirements as well.
"geometry": {"type":"Polygon","coordinates":[[[-73.98779153823898,40.718233223261],[-74.004946447098,40.723575517498],[-74.006771211624,40.730592217474],[-73.99010896682698,40.746712376146], [-73.973135948181,40.73974615047701],[-73.975120782852,40.736128627654],[-73.973997695541,40.730787341083],[-73.983317613602,40.716639396436],[-73.98779153823898,40.718233223261]]]}