Skip to main content

Hi Guys,

 

I am unable to transform the below input payload in json to expected output.

 

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":[

]

}

]

 

Expected Output:

(The value of flag is hardcoded)

[

{

"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'

}

Can you pl advice how to get the expected output.

 

Thanks

Yatan

5 answers
0/9000