I am trying to fetch this JSON array but didn't get the result. Can someone please tell me how can I do using volley. I need all the data within the booking. Please help me to achieve it.
{
"code": 200,
"savebooking": [
{
"Booking": {
"id": "304",
"contributor_id": "16",
"table_of_content_id": "6791",
"composition_id": "7469",
"completion": "2017-06-30",
"approved": null,
"cdn_id": "328301423",
"secret_token": "s-riQMc",
"uploaded_on": "2017-06-16 07:51:35",
"created": "2017-06-16 07:48:31",
"modified": "2017-06-16 07:51:35"
}
},
{
"Booking": {
"id": "305",
"contributor_id": "16",
"table_of_content_id": "6791",
"composition_id": "7470",
"completion": "2017-06-30",
"approved": null,
"cdn_id": "328318377",
"secret_token": "s-naSse",
"uploaded_on": "2017-06-16 10:43:39",
"created": "2017-06-16 07:48:31",
"modified": "2017-06-16 10:43:39"
}
},
{
"Booking": {
"id": "306",
"contributor_id": "16",
"table_of_content_id": "6791",
"composition_id": "7471",
"completion": "2017-06-30",
"approved": null,
"cdn_id": null,
"secret_token": null,
"uploaded_on": null,
"created": "2017-06-16 07:48:31",
"modified": "2017-06-16 07:48:31"
}
},
{
"Booking": {
"id": "307",
"contributor_id": "16",
"table_of_content_id": "6791",
"composition_id": "7472",
"completion": "2017-06-30",
"approved": null,
"cdn_id": null,
"secret_token": null,
"uploaded_on": null,
"created": "2017-06-16 07:48:31",
"modified": "2017-06-16 07:48:31"
}
}
]
}
How can I parse this JSON response using volley? I have tried this but didn't get the result.
StringRequest postStringRequest = new StringRequest(Request.Method.POST, BOOK_API,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d(TAG, "Response Check :" + response);
try {
JSONObject json = new JSONObject(response);
JSONObject booking = json.getJSONArray("savebooking").getJSONObject("Booking");
Log.d(TAG, "booking Response Check :" + booking);
} catch (JSONException e) {
e.printStackTrace();
}
}
});