How to remove specific key and its value from JSON in MuleSoft using DataWeave?

How to remove specific key and its value from JSON in MuleSoft using DataWeave?

Sample Code:

 %dw 2.0 
output application/json 
--- 
payload filterObject ((value, key) -> (key as String != "Test"))

In the above code
1. filterObject is used to filter JSON payload.
2. key as String is used since key is not an equivalent to String.
3. != is used to select all keys and values except “Test”.

The above code removes key “Test” and it’s values from the payload.

Leave a Reply