修改节点名称 @param jsonPath @param nodeName
(String jsonPath, String nodeName)
| 126 | * @param nodeName |
| 127 | */ |
| 128 | public void edit(String jsonPath, String nodeName) { |
| 129 | jsonPath = jsonPath.replaceAll("\\.", "/"); |
| 130 | int id = jsonPath.lastIndexOf("/"); |
| 131 | String key = jsonPath; |
| 132 | JSONObject object = jsonObj; |
| 133 | if (id != -1) { |
| 134 | key = jsonPath.substring(id + 1); |
| 135 | jsonPath = jsonPath.substring(0, id); |
| 136 | object = (JSONObject) getIt(jsonPath); |
| 137 | } |
| 138 | try { |
| 139 | object.put(nodeName, object.get(key)); |
| 140 | object.put(key, null); |
| 141 | } catch (JSONException e) { |
| 142 | e.printStackTrace(); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * 获取指定节点元素个数 |