您的位置:首页 > 移动开发 > Objective-C

复杂字符串转List<JSONObject>

2018-02-07 16:16 267 查看
public static List<JSONObject> getlist(String data){
ObjectMapper mapper = new ObjectMapper();
JavaType javaType = getCollectionType(ArrayList.class, JSONObject.class);
List<JSONObject> list = null;
try {
list = mapper.readValue(data,javaType);
} catch (IOException e) {
e.printStackTrace();
}
return list;
}
public static JavaType getCollectionType(Class<?> collectionClass, Class<?>... elementClasses) {
return new ObjectMapper().getTypeFactory().constructParametricType(collectionClass, elementClasses);
}

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: