how to remove specific fields from map using dataweave
input:
{ a:1, b:2, c:3, d:4 }
I want to remove c and d fields(c and d values are dynamic) and display only output
{ a:1, b:2 }
How can we do it in data weave
how to remove specific fields from map using dataweave
input:
{ a:1, b:2, c:3, d:4 }
I want to remove c and d fields(c and d values are dynamic) and display only output
{ a:1, b:2 }
How can we do it in data weave
According to the Dataweave Reference Documentation, you can remove a field from an object. Try using this:
%dw 1.0
%output application/json
---
payload - "c" - "d"
Below code works fine:
%dw 2.0
var arr=["c","d"]
output application/json
---
payload filterObject ((value, key, index) -> !(arr contains (key) as String))
You can add/remove the keys that you want to exclude in the variable 'arr'.