直接上代码:
JSONObject jsonObject = new JSONObject();
jsonObject.add("name",null);
String str = jsonObject.toString();//{}
str = JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue);//{"name",null}
直接上代码:
JSONObject jsonObject = new JSONObject();
jsonObject.add("name",null);
String str = jsonObject.toString();//{}
str = JSONObject.toJSONString(jsonObject, SerializerFeature.WriteMapNullValue);//{"name",null}