/** * 添加时,拼接json * * @param list_model_three * @param list_model_one * @return */ private String getJsonDataAdd( List<Model_three> list_model_three, List<Model_one> list_model_one) { JSONArray arr_three = null; JSONObject jsonObject_model_one = null; JSONArray arr_two = null; try { arr_two = new JSONArray(); for (int m = 0; m < list_model_one.get(0).getHeader_questions().size(); m++) { arr_three = new JSONArray(); for (int n = 0; n < list_model_one.get(0).getHeader_questions().get(m).getQuestions().size(); n++) { JSONObject jsonObject_three = new JSONObject(); Model_three model_three = list_model_one.get(0).getHeader_questions().get(m).getQuestions().get(n); jsonObject_three.put("question", model_three.getQuestion()); jsonObject_three.put("value", model_three.getValue()); jsonObject_three.put("in_sum", model_three.isIn_sum()); arr_three.put(jsonObject_three); } JSONObject jsonObject_model_two = new JSONObject(); Model_two model_two = list_model_one.get(0).getHeader_questions().get(m); jsonObject_model_two.put("header", model_two.getHeader()); jsonObject_model_two.put("questions", arr_three); arr_two.put(jsonObject_model_two); } Model_one model_one = list_model_one.get(0); jsonObject_model_one = new JSONObject(); // arr_one=new JSONArray(); jsonObject_model_one.put("evaluation_person", person.getText().toString()); jsonObject_model_one.put("evaluation_time_note", spinner_value); jsonObject_model_one.put("evaluation_time", date_tv.getText().toString()); jsonObject_model_one.put("has_sum", model_one.isHas_sum()); jsonObject_model_one.put("has_grade", model_one.isHas_grade()); String groupid = getGroupId(); jsonObject_model_one.put("groupid", groupid); jsonObject_model_one.put("header_questions", arr_two); // params.put("model",jsonObject_model_one); // arr_one.put(jsonObject_model_one); // jsonData = new JSONStringer().object().key("data").value(arr_one).endObject().toString(); // L.d("aa", "arr_one=" + arr_one.toString()); L.d("aa", "jsonObject_model_one=" + jsonObject_model_one.toString()); // L.d("aa", " jsonData=" + jsonData); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } return jsonObject_model_one.toString(); }
/** * radiobutton是否全部选中 * * @param list_model_three * @return */ private boolean radioButtonIsEmpty(List<Model_three> list_model_three) { for (Model_three model_three : list_model_three) { String value = model_three.getValue(); if (value.equals("-1000")) { return true; } } return false; }
/** * 编辑时,拼接json * * @param list_model_one * @return */ private String getJsonDataEdit(ArrayList<Model_one> list_model_one, Model_one model_one) { JSONArray arr_three = null; JSONArray arr_two = null; JSONObject jsonObject_model_one = null; try { arr_two = new JSONArray(); for (int m = 0; m < list_model_one.get(0).getHeader_questions().size(); m++) { arr_three = new JSONArray(); for (int n = 0; n < list_model_one.get(0).getHeader_questions().get(m).getQuestions().size(); n++) { JSONObject jsonObject_three = new JSONObject(); Model_three model_three = model_one.getHeader_questions().get(m).getQuestions().get(n); jsonObject_three.put("question", model_three.getQuestion()); jsonObject_three.put("value", model_three.getValue()); jsonObject_three.put("in_sum", model_three.isIn_sum()); jsonObject_three.put("id", model_three.getId()); arr_three.put(jsonObject_three); } JSONObject jsonObject_model_two = new JSONObject(); Model_two model_two = model_one.getHeader_questions().get(m); jsonObject_model_two.put("header", model_two.getHeader()); jsonObject_model_two.put("questions", arr_three); arr_two.put(jsonObject_model_two); } jsonObject_model_one = new JSONObject(); jsonObject_model_one.put("evaluation_person", person.getText().toString()); jsonObject_model_one.put("evaluation_time_note", spinner_value); jsonObject_model_one.put("evaluation_time", date_tv.getText().toString()); jsonObject_model_one.put("has_sum", model_one.isHas_sum()); jsonObject_model_one.put("has_grade", model_one.isHas_grade()); String groupid = getGroupId(); jsonObject_model_one.put("groupid", groupid); jsonObject_model_one.put("header_questions", arr_two); } catch (JSONException e) { e.printStackTrace(); } return jsonObject_model_one.toString(); }