Java fastjson JSON和String互相转换

时间:2019-11-25 22:43:31   收藏:0   阅读:455

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

 

原文:https://www.cnblogs.com/fubinhnust/p/11930585.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!