public String getBeanListString() throws JSONException { JSONArray jsonArr = new JSONArray(); for (HashMap<String, Object> map : getBeansList()) { JSONObject object = new JSONObject(); Iterator it = map.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); object.put(key, map.get(key)); } jsonArr.put(object); } return jsonArr.toString(); }
private void initHadoopProperties() { String hadoopProperties = getConnection().getHadoopProperties(); try { if (StringUtils.isNotEmpty(hadoopProperties)) { JSONArray jsonArr = new JSONArray(hadoopProperties); for (int i = 0; i < jsonArr.length(); i++) { HashMap<String, Object> map = new HashMap(); JSONObject object = jsonArr.getJSONObject(i); Iterator it = object.keys(); while (it.hasNext()) { String key = (String) it.next(); map.put(key, object.get(key)); } properties.add(map); } } } catch (JSONException e) { e.printStackTrace(); } }