I would like to filter an array based on another array values. I would like to filter the input array based on key value "KNVP-PARVW" is in the list of ["BP,SH,PY"]
here is the input:
[{
"KNVP-KUNNR": "100098",
"KNVP-VTWEG": "A1",
"KNVP-PARVW": "BP",
"KNVP-PARZA": "000",
"KNVP-KUNN2": "200115",
"KNVP-DEFPA": ""
},
{
"KNVP-KUNNR": "100098",
"KNVP-VTWEG": "A1",
"KNVP-PARVW": "SH",
"KNVP-PARZA": "001",
"KNVP-KUNN2": "200115",
"KNVP-DEFPA": ""
},
{
"KNVP-KUNNR": "100098",
"KNVP-VTWEG": "A1",
"KNVP-PARVW": "ZR",
"KNVP-PARZA": "000",
"KNVP-KUNN2": "256",
"KNVP-DEFPA": ""
}]
and here is my dataweave code:
%dw 2.0
var relationList=["BP,SH,PY"]
output application/json
---
payload filter ( relationList contains $."KNVP-PARVW" )