标签:java io ar on new c js 对象 as
用系统自带包:org.json就可以
List集合封装了object,下面是list到json
/**
*
* @param list
* 存放书签的集合
* @return json格式对象
*/
private static JSONObject listTojsoJsonObject(List<CalendarEvent> list) {
JSONObject jsonObj = new JSONObject();
try {
jsonObj.put("calendarEvents", list);
} catch (JSONException e) {
// The JSONException is thrown by the JSON.org classes when things
// are amiss.
e.printStackTrace();
}
return jsonObj;
}
**
*
* @param json
* @return list
* @throws JSONException
*/
public static List<CalendarEvent> jsonTolist(JSONObject json)
throws JSONException {
List<CalendarEvent> list = (List) json.get("calendarEvents");
return list;
}
标签:java io ar on new c js 对象 as
原文地址:http://blog.csdn.net/shaohx0518/article/details/38899651