JSON類型的String轉成List


//后端調用接口 
List<String> directives = new ArrayList<>();
while (matcher.find()) {
directives.add(matcher.group(1));
LOGGER.info("處理標簽:{}", matcher.group(1));
}
JSONObject jsonObject = new JSONObject();

Map map2=new HashMap();
//將List<String> 轉為JSON存儲 放入map中
map2.put("marksList",JSON.toJSONString(directives));
map2.put("userId","SU000000000195");
JSONObject obj2 = PostInterface.post(PostInterface.ServletName.placeholder,"queryPlaceHolderByMarks",map2).getJSONObject("SvcCont");
List<Placeholder> pList = JSON.parseArray(obj2.getString("placeHolderList"),Placeholder.class);

 

//接口中解析

JSON中string轉List<String>
List<String> pList = JSON.parseArray(svcCont4PlaceHolderReq.getMarksList(),String.class);


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM