1. 程式人生 > >fastjson List轉JSONArray以及JSONArray轉List

fastjson List轉JSONArray以及JSONArray轉List

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);