I am mapping my payload to a new payload and adding an Errors array in where the output looks like this. :
payload : [{
"test: "test",
"test2" : "",
"test3" : "test3"
},
{
"test: "test",
"test2" : "test2",
"test3" : "test3"
}]
Expected output : ` payload : [{
"test: "test",
"test2" : "",
"test3" : "test3",
"Errors" : {
"test2" : "Test2 is NULL"
}
},
{
"test: "test",
"test2" : "test2",
"test3" : "test3",
"Errors" : {
}
}]`
Expected Output : I want to get an output where I only get all objects from Payload where Errors array has any key with not null values otherwise it should be filtered out.
I am using below expression to achieve but this is not feasible as it requires me to add a null check for each key in Errors array.
errArr."Errors" filter ((item, index) -> item."test" != "" or item."test2" != "" or
item."test3" != "")
There has to be a better way to do this? Is there a way to just check values of every item (key)without defining their name?
null
in Dataweave. - GeorgeI want to get an output where I only get all objects from Payload where Errors array has any key with not null values otherwise it should be filtered out.
makes little sense to me. Form what I can gather based upon your specific input you should have an empty array. - George