Apply what you have learned, welcome to reprint, contact QQ:289325414 for more
Reprinted: https://blog.csdn.net/xlecho/article/details/81131561
Convert object to string
HashMap<String,Object> map=new HashMap<>(2);
map.put("studentNo","123");
map.put("subjectNo","321");
String strInfo = JSON.toJSONString(map);
Convert string to object
JSONObject map = JSON.parseObject(strInfoDo);
String studentNo=(String)map.get("studentNo")
String subjectNo=(String)map.get("subjectNo")
Convert a collection of objects into a string
String xmlStr= JSON.toJSONString(list);
--下面的方法比上面会快。快更多,非常多
(hutool.json)
JSONArray jsonArray=new JSONArray(list);
String xmlStr=jsonArray.toString();
Convert a string into a collection of objects
List<User> userList = JSON.parseArray(userStr, User.class);