I am at a loss why this JSONata is failing with the following error:'
Expected "}", got ":"
I am trying to prepare the JSON payload for a QuickBase API call:
This is not how I would have shaped this JSON but it is the 'contract'. I would not have used the value property but instead had a literal. The numbered properties relate to a field in a QuickBase table.
Note that flow.shipmentContents is an array of shipment lines:
{
"to": "bvhw2455g",
"data": [
$map(
flow.shipmentContents,
function($v) {
"8": {"value": $v.SALES_ORDER_ID & '-' $v.DOCUMENT_TYPE & '-' & $v.LINE_ID},
"9": {"value": $v.LINE_TYPE},
"11": {"value": $v.GTIN},
"12": {"value": $v.ITEM_DESCRIPTION},
"13": {"value": $v.ALT_DESCRIPTION},
"14": {"value": $v.DESCRIPTION},
"15": {"value": $v.QUANTITY_ORDERED - $v.QUANTITY_SHIPPED},
"16": {"value": $v.QUANTITY_ORDERED},
"22": {"value": flow.foreignKeyId}
}
)
],
"fieldsToReturn": [
1,
2
]
}
Google Gemini suggested wrapping the inner mapped object with (), as well as the concatenation but that does not help:
{
"to": "bvhw2455g",
"data": [
$map(
flow.shipmentContents,
function($v) {(
"8": {"value": ($v.SALES_ORDER_ID & '-' $v.DOCUMENT_TYPE & '-' & $v.LINE_ID)},
"9": {"value": $v.LINE_TYPE},
"11": {"value": $v.GTIN},
"12": {"value": $v.ITEM_DESCRIPTION},
"13": {"value": $v.ALT_DESCRIPTION},
"14": {"value": $v.DESCRIPTION},
"15": {"value": $v.QUANTITY_ORDERED - $v.QUANTITY_SHIPPED},
"16": {"value": $v.QUANTITY_ORDERED},
"22": {"value": flow.foreignKeyId}
)}
)
],
"fieldsToReturn": [
1,
2
]
}
Thoughts?
Please don't tell me to use JavaScript instead.