skip null in json in mule skip null in json in mule json json

skip null in json in mule


To deal with JSON message in Java component, usually I utilize: net.sf.json.JSONObject, net.sf.json.JsonConfig, and net.sf.json.util.PropertyFilter.

Put them inside the transformMessage method, to intercept the incoming JSON message and remove all null properties.

JsonConfig jsonConfig = new JsonConfig();jsonConfig.setJsonPropertyFilter(new PropertyFilter() {    @Override    public boolean apply(Object source, String name, Object value) {        return (value == null);    }});return JSONObject.fromObject(message.getPayload(), jsonConfig);


The easiest part is to use the Dataweave but as you mention you are using community edition in that case I will suggest create your own custom transformer where you get this payload and check manually this null value and remove it.