Need to check null and empty array in Dataweave using filter or any other logic.
First check the parentId is null, we need to skip the particular JSON. If parentId is not null need to check the mobileContacts or emailContacts have the array of values. If mobileContacts and emailContacts have empty List we need skip the particular JSON values. If any one have the value we need to process the records.
Input JSON:
{
"name": "XYZ",
"age": 23,
"results": [
{
"parentId": "12345",
"notes": "proceed",
"mobileContacts": [
{
"relationId": "12345",
"callId": "3456213"
},
{
"relationId": "12345",
"callId": "12345"
}
],
"emailContacts": [ ],
"initial": true
},
{
"parentId": "435638",
"notes": "proceed",
"mobileContacts": [ ],
"emailContacts": [ ],
"initial": true
},
{
"parentId": null,
"notes": "proceed",
"mobileContacts": [
{
"relationId": "12345",
"callId": "3456213"
},
{
"relationId": "12345",
"callId": "12345"
}
],
"emailContacts": [ ],
"initial": true
}
]
}
Need below Output:
{
"name": "XYZ",
"age": 23,
"results": [
{
"parentId": "12345",
"notes": "proceed",
"mobileContacts": [
{
"relationId": "12345",
"callId": "3456213"
},
{
"relationId": null,
"callId": null
}
],
"initial": true
}
]
}