List转JSONArray和JSONArray转List
1.List转JSONArray
List<T> list = new ArrayList<T>();
JSONArray array= JSONArray.parseArray(JSON.toJSONString(list));
- 1
- 2
2.JSONArray转List
JSONArray array = new JSONArray();
List<EventColAttr> list = JSONObject.parseArray(array.toJSONString(), EventColAttr.class);
- 1
- 2
3.String转JSONArray
String st = "[{name:Tim,age:25,sex:male},{name:Tom,age:28,sex:male},{name:Lily,age:15,sex:female}]"; JSONArray tableData = JSONArray.parseArray(st);
dUserInfoDto
String="[1,2,3]"
List<Long> list = JSONArray.parseArray(dUserInfoDto,Long.class);
转载至:https://blog.csdn.net/weixin_42365088/article/details/99761931
我是个双鱼座的小王子,沉浸在自己的代码世界里,去探索这未知的世界,希望遇到更多的小伙伴一起前行!