//Javabean对象转换成String类型的JSON字符串
JSONObject.toJSONString(Javabean对象)
//String类型的JSON字符串转换成Javabean对象
JSONObject.toJavaObject(JSON字符串,Javabean.class)
//Json字符串转换成JSONObject对象
JSONObject.parseObject(JSON字符串)
//JSON字符串转换成Javabean对象
JSONObject.parseObject(JSON字符串,Javabean.class)
例如
Refund r = new Refund();
String jsonStr = JSONObject.toJSONString(r);
String jsonStr = "{\"msg\":\"ZhangSan\"}";
Refund r = JSONObject.toJavaObject(jsonStr,Refund.class);
JSONObject jsonObject = JSONObject.parseObject(jsonStr);
Refund r = JSONObject.parseObject(jsonStr,Refund.class);
---------------------
作者:a990914093
来源:CSDN
原文:https://blog.csdn.net/a990914093/article/details/81217581
版权声明:本文为博主原创文章,转载请附上博文链接!