How to remove a field from JSON payload using Dataweave

Remove a field from JSON object payload using Dataweave 2.0



Let us see how can we exclude a field or set of fields from the JSON array. We must use - "field name" to remove the field name from the JSON object.

Input:
{
"userId": 1,
"firstName": "Uday",
"lastName": "Kiran",
"role": "Developer",
"phoneNumber": "930293029",
"emailAddress": "hello@designgrows.com"
}

Dataweave code: To remove a field "phoneNumber"
%dw 2.0
output application/json
---
payload - "phoneNumber"

Output:
{
"userId": 1,
"firstName": "Uday",
"lastName": "Kiran",
"role": "Developer",
"emailAddress": "hello@designgrows.com"





Also read: How to change colors in Dataweave script Transform message 

Post a Comment

0 Comments