List与JSONArray互转
1.List转JSONArray
List<T> list = new ArrayList<T>();
JSONArray array= JSONArray.parseArray(JSON.toJSONString(list));
2.JSONArray转List
JSONArray array = new JSONArray();
List<Article> list = JSONObject.parseArray(array.toJSONString(), Article.class);
3.String转JSONArray
String str = "[{name:leixing,age:22,sex:1},{name:luo,age:18,sex:male}]"; JSONArray arr= JSONArray.parseArray(str);