JSONArray與list集合之間轉換(net.sf.json.JSONArray)

一、String-->JSONArray-->List

String str="";
JSONArray jsonArray = JSONArray.fromObject(str);
List<String> list = (List)JSONArray.toCollection(jsonArray,Website.class);

二、List-->JSONArray-->String

List<String> stringList=new ArrayList<>();
JSONArray json = JSONArray.fromObject(stringList);
String string=json.toString();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章