Fastjson格式转换

1. List转JSONArray

 

List<T> list = new ArrayList<T>();

JSONArray array= JSONArray.parseArray(JSON.toJSONString(list));

 

 

2.JSONArray转List

 

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

 

 

3. 字符串转List

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

 

posted @ 2019-01-09 09:08  七柏  阅读(271)  评论(0编辑  收藏  举报