json

public JSONArray getJson(long id) {
  JSONArray jsons = new JSONArray();
  JSONObject  jo = null;
  List<ShrgSchScheduleInfoT>  list = MinuteRingFactory.getMinuteRingFactory().getInstance().getMinuteRing(id);
  for (ShrgSchScheduleInfoT shrgSchScheduleInfoT : list) {
     jo = new JSONObject();
     try {
    jo.put("name", shrgSchScheduleInfoT.getName());
    jo.put("classStartTime", shrgSchScheduleInfoT.getClassStartTime());
    jo.put("classOverTime", shrgSchScheduleInfoT.getClassOverTime());
    jo.put("classRing", shrgSchScheduleInfoT.getClassRing());
    jsons.put(jo);
   } catch (JSONException e) {
    e.printStackTrace();
   }
   
  }
  return jsons;
 }
 
 @Test
 public void getJson(){
  JSONArray jsons = new JSONArray();
  JSONObject  jo = null;
  List<ShrgSchScheduleInfoT>  list = MinuteRingFactory.getMinuteRingFactory().getInstance().getMinuteRing(2);
  for (ShrgSchScheduleInfoT shrgSchScheduleInfoT : list) {
     jo = new JSONObject();
     try {
    jo.put("name", shrgSchScheduleInfoT.getName());
    jo.put("classStartTime", shrgSchScheduleInfoT.getClassStartTime());
    jo.put("classOverTime", shrgSchScheduleInfoT.getClassOverTime());
    jo.put("classRing", shrgSchScheduleInfoT.getClassRing());
    jsons.put(jo);
   } catch (JSONException e) {
    e.printStackTrace();
   }
   
  }
  System.out.println(jsons);
 }
 
發佈了28 篇原創文章 · 獲贊 1 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章