【fastjson】List转JSONArray以及JSONArray转Lis

1.fastjson—List转JSONArray

List<T> list = new ArrayList<T>();
JSONArray array= JSONArray.parseArray(JSON.toJSONString(list))

2.fastjson—JSONArray转List

JSONArray array = new JSONArray();
List<EventColAttr> list = JSONObject.parseArray(array.toJSONString(), EventColAttr.class);

3.fastjson—字符串转List

String str = "";
List<T> list = JSONObject.parseArray(str,T.class);

4.fastjson—list集合转换为json字符串

JSON.stringify(list)

你可能感兴趣的:(日常积累)