あなたが学んだことを適用し、再版へようこそ、詳細についてはQQ:289325414にお問い合わせください
転載:https://blog.csdn.net/xlecho/article/details/81131561
オブジェクトを文字列に変換する
HashMap<String,Object> map=new HashMap<>(2);
map.put("studentNo","123");
map.put("subjectNo","321");
String strInfo = JSON.toJSONString(map);
文字列をオブジェクトに変換する
JSONObject map = JSON.parseObject(strInfoDo);
String studentNo=(String)map.get("studentNo")
String subjectNo=(String)map.get("subjectNo")
オブジェクトのコレクションを文字列に変換します
String xmlStr= JSON.toJSONString(list);
--下面的方法比上面会快。快更多,非常多
(hutool.json)
JSONArray jsonArray=new JSONArray(list);
String xmlStr=jsonArray.toString();
文字列をオブジェクトのコレクションに変換します
List<User> userList = JSON.parseArray(userStr, User.class);