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);