首先导包:
import com.alibaba.fastjson.JSONObject;
String转JSON:
//result为要转JSON的String字符串
JSONObject jsonObject = JSONObject.parseObject(result);
JSON转JAVA对象:
//Object为要转JAVA对象,可以为任意JAVA类,例:Student-->
//Student student=(Student)JSONObject.toJavaObject(jsonObject, Student.class);
//jsonObject为要转JAVA对象的JSON
Object object=(Object)JSONObject.toJavaObject(jsonObject, Object.class);