Im sorry for asking such a simple question, im struggling to get the values in JSONArray in the JSONArray without the variables inside the Array. Im using Retrofit library in android studio.Give me link or hint to get the value, please help. TQ in advance.
And here is the JSON format:
{
"meta":{
"code":200
},
"response":{
"provider":"jakim",
"code":"wlp-0",
"origin":"wlp-0",
"jakim":"sgr03",
"source":"http:\/\/www.e-solat.gov.my\/web\/muatturun.php?zone=sgr03&year=2018&bulan=7&jenis=year&lang=my&url=http:\/\/mpt.i906.my",
"place":"Kuala Lumpur",
"times":[
[
1531691280,
1531696200,
1531718520,
1531730760,
1531740600,
1531745100
],
[ ],
[ ],
[ ],
[ ],
[ ],
[ ]
]
}
}
or can view the link for json: json link here
Here is my code:
private void getPrayTimeMalay(String code, String filter) {
ApiServiceInterface apiEndPoint = Utility.getRetrofitInstanceMalay().create(ApiServiceInterface.class);
Call<ResponseBody> call = apiEndPoint.getPrayerTimeMalay(code, filter);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
try {
String tmp = response.body().string();
JSONObject jsonData = new JSONObject(tmp);
Log.d("getPrayer", "onResponse: " + jsonData);
JSONObject jsonMeta = jsonData.getJSONObject("meta");
JSONObject jsonResponse = jsonMeta.getJSONObject("response");
if (jsonMeta.getInt("code") == 200) {
PrayerTime prayerTime = new PrayerTime();
prayerTime.code = jsonResponse.getString("code");
prayerTime.origin = jsonResponse.getString("origin");
prayerTime.place = jsonResponse.getString("place");
JSONArray jsonTime = new JSONArray("times");
for (int i = 0; i <= jsonTime.length(); i++) {
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
}
});
}