Easy way to skip the field(s) which is NULL – MuleSoft 4

Problem:

Sometimes to work with MuleSoft Anypoint Studio, we have payload with fields contain a null value.
For example:
Input Payload:

{

"id": 001,
"firstName": "John",
"lastName": null,
"phoneNumber": null,
"email": "abc@domain.com"

}

 

You want to keep the fields which have a value. You want to skip the NULL value fields.

Expected Payload:

{

"id": 001,
"firstName": "John",
"email": "abc@domain.com"

}

Solution:

You can do it very easily in ‘Transform Message / Data Weave’, in MuleSoft Anypoint Studio.

%dw 2.0
output application/json skipNullOn="everywhere"
{
"id": payload.'id', 
"firstName": payload.'firstName',
"lastName": payload.'lastName',
"phoneNumber": payload.'phoneNumber',
"email": payload.'email'

}

Just add skipNullOn=”everywhere” after ‘output application/JSON’

Note:

This attribute only works when the output is in JSON or XML. It will not work for output ‘java’.



 

Share This Post

More To Explore

Productivity with MuleSoft RPA
Blogs

Top 5 reasons to invest in MuleSoft RPA

Having trouble feeding data into your system repetitively? Or having to extract a bunch of emails from months past? Or are you overloaded with complex

How can we help?

A little about yourself and we're ready to go

We pride ourselves on swift communication and prompt responses. Let us know what you're thinking and how we can help you.

Contact Information​

Head Office
18 King Street E, Suite 1400, Toronto ON M5C 1C4, Canada

Durham Office
Unit 265, 1099 Kingston Rd. Pickering, ON. L1V1B5, Canada

Austin Office
5900 Balcones Dr, STE 4000 Austin, TX 78731, USA

Dallas Office
Unit 113, 320 Decker Drive, Irving, Texas, TX 75062, USA

Phone: +1(877) 855-8775
Email: info@plektonlabs.com

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Going into 2023, data will continue to be the most valuable asset for businesses! You need to know how to maximize the value of your data via integration. Learn more here.