JSONObjec序列化对象过滤为null的属性
@Test public void test3() { PgwReqtBody3002 pgwReqtBody3002 = new PgwReqtBody3002(); pgwReqtBody3002.setService("1"); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setJsonPropertyFilter(new PropertyFilter() { @Override public boolean apply(Object obj, String key, Object value) { if (value == null) { return true; } return false; } }); JSONObject j = JSONObject.fromObject(pgwReqtBody3002, jsonConfig); System.out.println(j.toString()); }