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