解决 JSONObject.fromObject 转换时的空值

JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerDefaultValueProcessor(Integer.class, new DefaultDefaultValueProcessor() {
            public Object getDefaultValue(Class type) {
                return "";
            }
        });
jsonConfig.registerDefaultValueProcessor(Double.class, new DefaultDefaultValueProcessor() {
            public Object getDefaultValue(Class type) {
                return "";
            }
        });
JSONObject json = JSONObject.fromObject(pc,jsonConfig);

 

你可能感兴趣的:(java)