/** * * * @param jsonArray * @param clazz * @param <T> * @return */ public static <T> List<T> jsonArrayToList(JSONArray jsonArray, Class<T> clazz) { if (jsonArray == null) { Log.w(TAG, "jsonArray is null"); return Collections.emptyList(); } List<T> list; try { list = JSON.parseArray(jsonArray.toJSONString(), clazz); } catch (JSONException e) { e.printStackTrace(); Log.e(TAG, "json is error = " + jsonArray); list = Collections.emptyList(); } if (list == null || list.size() < 1 || list.isEmpty()) { Log.w(TAG, "list is null"); return Collections.emptyList(); } return list; }
json数组转成list表
最新推荐文章于 2024-03-16 11:06:18 发布