Java中 List 和 JSON字符串之間的相互轉(zhuǎn)換
List 轉(zhuǎn) JSON 字符串
List list = new ArrayList();
Map<String,String> map = new HashMap<>();
map.put("name","szy");
map.put("num",2);
list.add(map);
String inventoryResultStr = JSON.toJSON(list).toString();
前端js將后端的json字符串轉(zhuǎn)對象文章來源:http://www.zghlxwxcb.cn/news/detail-856098.html
var strJson1 ='${inventoryResultStr}';
var verficationPeopleMap=JSON.parse(strJson1);
JSON字符串轉(zhuǎn)List文章來源地址http://www.zghlxwxcb.cn/news/detail-856098.html
List inventoryResultList = JSONObject.parseArray(inventoryResult);
for(Integer i=0;i<inventoryResultList.size();i++){
JSONObject jsonObject = (JSONObject) inventoryResultList.get(i);
String name =jsonObject.getString("name");
}
到了這里,關(guān)于Java中 List 和 JSON字符串之間的相互轉(zhuǎn)換的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!