FastJSON--Java对象、集合转换成JSONObject、JSONArray

时间:2020-12-11 18:24:07   收藏:0   阅读:339
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()) ) ;

原文:https://blog.51cto.com/1929297/2562748

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!