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?
question from:
https://stackoverflow.com/questions/65878126/how-to-check-if-any-values-in-an-array-is-not-null-in-dataweave-2-0 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…