Ashish Choudhary Ashish Choudhary - 7 days ago 4x
JSON Question

getting null value while parsing json data in android

i am trying to parse json data in android app i am able to get title of the book and author but i am not able to parse publisher i am getting null value at publisher

"title":"Professional Android 4 Application Development",
"Reto Meier"
"publisher":"John Wiley & Sons",

here is the java code written for Json

JSONObject root = new JSONObject(jsonResponse);
JSONArray itemsArray = root.optJSONArray("items");
for (int i=0;i<itemsArray.length();i++){

JSONObject singleItem = itemsArray.getJSONObject(i);

JSONObject volumeInfo = singleItem.getJSONObject("volumeInfo");
String title = volumeInfo.getString("title");

String author = volumeInfo.getString("authors");
String publisher = singleItem.getString("publisher");


It seems that the publisher is contained by volumeInfo. Try:

String publisher = volumeInfo.getString("publisher");