With JSONata how do I add external data to an existing array, I have an array of phone numbers, I want to call them communications, I can create the array but I want to add the email as a communications type but its outside of the array.
"customer": {
"email": "joe@home.com",
"doNotEmail":"true",
"phones": [
{
"key": "0",
"number": "2222222222",
"preferredContactTime": "UNKNOWN",
"sendTextMessages": false,
"type": "HOME"
},
{
"key": "1",
"number": "3333333333",
"preferredContactTime": "UNKNOWN",
"sendTextMessages": false,
"type": "HOME"
},
{
"key": "2",
"number": "2222222222",
"preferredContactTime": "UNKNOWN",
"sendTextMessages": false,
"type": "HOME"
}
]
}
Tried:
"communication": $append(customer.phones.{
"channelType": "Phone",
"channelCode": type,
"completeNumber": number
},{$$.customer.email, $$.customer.privacy.okToContact),
Expeting:
"communication": [
{
"emailAddress": "joe@home.com",
"channelType": "Email",
"channelCode": "Personal",
"privacy": [
{
"okToContact": true
}
]
},
{
"channelType": "Phone",
"channelCode": "Home",
"completeNumber": "222-222-2222"
},
{
"channelType": "Phone",
"channelCode": "Home",
"completeNumber": "333-333-3333"
},
{
"channelType": "Phone",
"channelCode": "Home",
"completeNumber": "222-222-2222"
}
]