//1、使用JSONObject net.sf.json;
JSONObject jsonObject=JSONObject.fromObject(objectStr);
Student stu=(Student)JSONObject.toBean(jsonObject, Student.class);
String objectStr="{“name”:“JSON”,“age”:“24”,“address”:“北京市西城区”}";
//2、使用JSONArray
JSONArray jsonArray=JSONArray.fromObject(arrayStr);
//获得jsonArray的第一个元素
Object o=jsonArray.get(0);
JSONObject jsonObject2=JSONObject.fromObject(o);
Student stu2=(Student)JSONObject.toBean(jsonObject2, Student.class);
String arrayStr="[{“name”:“JSON”,“age”:“24”,“address”:“北京市西城区”}]";
JSON字符串和java对象的互转【json-lib】
链接