I am unable to transform the below input payload in json to expected output. Below is the input I got, and the mapping which I tried, I have to ignore when the value of bea_order is blank which can we done with the filter, however my requirement is to pickup all the values from inside the array and club them together with values from other arrays.
Input:
[
{
"bea_order":[
]
},
{
"bea_order":[
{
"PO_Receipt_Date__c":"2021-08-13",
"Id":"a3I1T000003E6SQUA0"
},
{
"PO_Receipt_Date__c":null,
"Id":"a3Iq0000000OhnREAS"
},
{
"PO_Receipt_Date__c":null,
"Id":"a3Iq0000000OhnWEAS"
}
]
},
{
"bea_order":[
{
"PO_Receipt_Date__c":"2022-05-06",
"Id":"a3I1T000003E6SOUA0"
}
]
},
{
"bea_order":[
]
}
]
Output:
[
{
"id":"a3I1T000003E6SQUA0",
"flag":"false"
},
{
"id":"a3Iq0000000OhnREAS",
"flag":"false"
},
{
"id":"a3Iq0000000OhnWEAS",
"flag":"false"
},
{
"id":"a3I1T000003E6SOUA0",
"flag":"false"
}
]
Mapping I tried:
%dw 2.0
output application/json
---
payload.bea_order filter ($.Id != null) map () -> {
id : $.Id,
flag : 'false'
}
How to get the expected output?