3
内部ストレージでの私のJSONファイルの
形式が似ている、JSONファイルの配列内の特定のオブジェクトを更新するにはどうすればいいですか?
{
"appointments": [
{
"appointmentId": "app_001",
"appointmentTitle": "Appointment Title1",
"appointmentDate": "2017-11-25",
"appointmentTime": "10:30",
"appointmentStatus": "active",
"appointmentType": "meeting",
"reminder": {
"type": "notification",
"time": "10:15",
"status": "off"
},
"appointmentDescription": "blablablablabla1"
},
{
"appointmentId": "app_002",
"appointmentTitle": "AppointmentTitle2",
"appointmentDate": "2017-11-26",
"appointmentTime": "09:00",
"appointmentStatus": "done",
"appointmentType": "exam",
"reminder": {
"type": "alarm",
"time": "08:45",
"status": "on"
},
"appointmentDescription": "blablablablabla2"
}
]
}
私はapp_001
私の機能がどうあるべきか、
String configFileString = "";
File configFile = new File(getApplicationContext().getExternalFilesDir("/appointments"), "appointments.json");
try {
configFileString = getStringFromFile(configFile.toString());
JSONObject json = new JSONObject(configFileString);
JSONArray array = json.getJSONArray("appointments");
} catch (Exception e) {
e.printStackTrace();
}
ある
appointmentId
などがあり
appointmentTitle
の値を更新する必要があります私のコードで行う必要がある変更?事前に感謝してください、助けてください。
ちょうどそのよう。オブジェクトのタイトルまたはオブジェクトの値を変更したいですか? – Nero
@Nero値を記載しました – ChyperX