Пример #1
0
 public static java.util.List<Purchase> arrayToList(JSONArray array) {
   java.util.List<Purchase> list = new java.util.ArrayList<Purchase>();
   for (int i = 0, len = array.size(); i < len; i++) {
     JSONObject jsonObject = array.getJSONObject(i);
     Purchase model = jsonToObject(jsonObject);
     list.add(model);
   }
   return list;
 }
Пример #2
0
 public static JSONArray listToArray(java.util.List<Purchase> list) {
   JSONArray array = new JSONArray();
   if (list != null && !list.isEmpty()) {
     for (Purchase model : list) {
       JSONObject jsonObject = model.toJsonObject();
       array.add(jsonObject);
     }
   }
   return array;
 }