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