更新时间:2023-12-02 22:35:52
JSONObject jsonObject = new JSONObject("Your_JSON_String");
JSONObject jsonObjectForState = jsonObject.getJSONObject("State");
jsonObjectForState.put("Sname", "New_Value_Here");
put(...)
将用新值替换当前值.同样,您可以更新其他值.完成后,您可以使用以下方法将其转换回去:
put(...)
will replace the current value with new value. Similarly, you can update the other values. Once you are done, you can convert it back using:
jsonObject.toString();
并将其写回到文件中.