{
"ProfileDetails":
[
{
"status":"success",
"1":{"id":"1","user_id":null,"date_in":"2020-07-19","time_in":"11:01:05","date_out":"2020-07-19","time_out":"20:02:36","complete":"yes","approve":"","timestamp":null},
"2":{"id":"3","user_id":null,"date_in":"2020-07-21","time_in":"11:01:00","date_out":"2020-07-21","time_out":"16:02:36","complete":"no","approve":"yes","timestamp":null},
"3":{"id":"4","user_id":null,"date_in":"2020-07-22","time_in":"11:01:00","date_out":"2020-07-22","time_out":"16:02:36","complete":"no","approve":"no","timestamp":null},
"total":3
}
]
}
我如何才能检索“ date_in”等个人对“ 1”的价值? 我已经完成以下代码:
JSONObject object = new JSONObject(response);
JSONArray array = object.getJSONArray("ProfileDetails");
// getting login_details from json array
JSONObject profile = array.getJSONObject(0);
String status = profile.getString("status");
if (status.equals("success")) {
total = profile.getString("total");
total1 = Integer.parseInt(total);
for(i = 1; i<= total1; i++){
i1 = String.valueOf(i);
i1 = profile.getString(i1);
JSONObject inner = array.getJSONObject(0);
date_in = inner.getJSONObject(i1).getString("date_in");
time_in = inner.getString("time_in");
time_out = inner.getString("time_out");
complete = inner.getString("complete");
Log.d("Element:",i1);
// Log.d("Element1:",date_in);
// Log.d("Element2:",time_in);
// Log.d("Element3:",time_out);
// Log.d("Element4:",complete);
}
}