java json字符串转JSONObject对象、转JAVA对象、转List对象

String jsonData = ""; //json格式的字符串

JSONObject jsonObj = JSONObject.parseObject(jsonData);//转JSONObject对象
String name = jsonObj.get("name").toString(); //取JSONObject对象中的数据
Student stu = JSONObject.parseObject(jsonData, Student.class); //json字符串直接转给java对象
List<Student> list = JSONArray.parseArray(jsonData, Student.class); //json字符串直接转为List<java>对象


List<Map<String, Object>> mapList = (List<Map<String, Object>>)JSONObject.parse(jsonData);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章