/** * 解析数据JSON * * @param strResult * @return */ public static ArrayList<NormalTableFinalModel> parseJson( String strResult, ArrayList<NormalTableModel> list_info) { ArrayList<NormalTableModel> list_model = null; ArrayList<NormalTableFinalModel> list_final_model = null; NormalTableFinalModel model = null; try { JSONObject jsonObject = new JSONObject(strResult); JSONArray jsonArray = jsonObject.getJSONArray("data"); list_final_model = new ArrayList<>(); if (!jsonArray.toString().equals("[]")) { for (int i = jsonArray.length() - 1; i >= 0; i--) { JSONObject object = jsonArray.getJSONObject(i); list_model = new ArrayList<>(); try { list_model = deepCopy(list_info); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } for (int j = 0; j < list_model.size(); j++) { list_model.get(j).setMiddleText(object.getString(list_model.get(j).getName())); } model = new NormalTableFinalModel(); model.setIsEmpty("no"); model.setModel_name(jsonObject.getString("model_name")); model.setId(jsonArray.getJSONObject(i).getString("id")); model.setList_model(list_model); list_final_model.add(model); } } else { model = new NormalTableFinalModel(); model.setIsEmpty("yes"); model.setModel_name(jsonObject.getString("model_name")); list_model = new ArrayList<>(); try { list_model = deepCopy(list_info); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } model.setList_model(list_model); list_final_model.add(model); } } catch (Exception e) { L.d("yy", "NormalTableFinalModel Parse Error"); e.printStackTrace(); } return list_final_model; }