1、json转string
JSONObject json=new JSONObject();
String str = json.toString();
2、String转Json:
String str="";
JSONObject json=new JSONObject();
JSONObject jsonObject = json.parseObject(str);
3、实体对象转Json:
String string = JSONObject.toJSONString(bean,SerializerFeature.WriteMapNullValue); //防止空值丢字段 JSONObject jsonObject = JSONObject.parseObject(string);