I want to get a specific value from my nested JSON object like this:
{
"success": true,
"data": [
{
...
},
{
"id": 5,
"nama": "Ngagoes Ulin Kalembur",
"harga": 250000,
"deskripsi": "Menikmati serunya berwisata keliling desa-desa di sekitaran desa alamendah menggunakan sepeda, menyusuri pemukiman, kebun-kebun dan pemandangan anda akan menemukan hal menarik selama perjalanan di desa alamendah, Pengemasan sayuran, pengrajin sovenir dll.",
"gambarid": 11,
"paketan": true,
"fasilitas": "Sepeda,Angkutan Umum,Wisata Perternakan,Wisata Kuliner,Wisata Pertanian,Snack,Pemandu Lokal,Air Mineral",
"totalTiket": 100,
"minTiket": 50,
"createdAt": "2021-03-07T10:44:10.000Z",
"updatedAt": "2021-04-28T13:07:05.000Z",
"deletedAt": null,
"gambarId": 11,
"Gambar": {
"id": 11,
"url": "https://desaalamendah.id/images/upload/ImageWisata-1615114030139.png",
"isGallery": null,
"createdAt": "2021-03-07T10:44:10.000Z",
"updatedAt": "2021-03-07T10:47:10.000Z",
"deletedAt": null
}
},
I already try for() and if() condition like this:
@override
public void onResponse(Call<JSONResponse> call, Response<JSONResponse> response)
{
JSONResponse jsonResponse = response.body();
wisataList = new ArrayList<>(Arrays.asList(jsonResponse.getData()));
Intent intent = getIntent();
int id = intent.getIntExtra(HomeActivity.EXTRA_NUMBER, 0);
for (int i = 0; i<jsonResponse.getData().length; i++)
{
if (id == i)
{
PutDataIntoRecyclerView(wisataList);
}
}
}
When I run it, it keeps returning all of the values. How to get a specific value, for example id = 3, from my nested JSON object?