Student student=new Student();
// Java对象转JSONObect对象
JSONObject jsonObject=(JSONObject) JSONObject.toJSON(studentDTO.getCla***oom());
JSONObject jsonObject2=JSONObject.parseObject(JSON.toJSONString(student.getCla***oom()));
student.setCla***oom(jsonObject);
// Java集合转JSON数组
JSONArray jsonArray=(JSONArray) JSONArray.toJSON(studentDTO.getTeachers());
JSONArray jsonArray2= JSONArray.parseArray( JSON.toJSONString(studentDTO.getCla***oom()) ) ;
FastJSON--Java对象、集合转换成JSONObject、JSONArray
原文:https://blog.51cto.com/1929297/2562748