title: Google Books Api - No value for imageLinks - Android JSONException
body: <p>I'm using <code>Google Books Api</code> to show list of books, but when I try to get thumbnail url from <code>imageLinks</code> <code>JSONObject</code>, then the <code>JSONException</code> says that there's no value for <code>imageLinks</code> even though the value exists in this object.</p>
  
  <p>I tried methods like <code>JSONObject.isNull()</code> or <code>optString()</code> instead of <code>getString()</code>, but it still doesn't give me any value.</p>
  
  <p>Here's the URL that I'm trying to get data from: <a href="https://www.googleapis.com/books/v1/volumes?q=android" rel="nofollow noreferrer">https://www.googleapis.com/books/v1/volumes?q=android</a></p>
  
  <p>Here's the code:</p>
  
  <pre><code>JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener &lt; JSONObject &gt; () {
   @Override
   public void onResponse(JSONObject response) {
    if (response != null) {
     try {
      JSONArray jsonItemsArray = response.getJSONArray("items");
      for (int i = 0; i &lt; jsonItemsArray.length(); i++) {
       String thumbnailUrl = "";
       String title = "";
       JSONObject item = jsonItemsArray.getJSONObject(i);
       JSONObject volumeInfo = item.getJSONObject("volumeInfo");
       JSONObject thumbnailUrlObject = volumeInfo.getJSONObject("imageLinks");
       if (!thumbnailUrlObject.isNull("thumbnail")) {
        thumbnailUrl = thumbnailUrlObject.getString("thumbnail");
       }
       title = volumeInfo.getString("title");
       bookList.add(new Book(title, thumbnailUrl));
       booksAdapter.notifyDataSetChanged();
      }
  
     } catch (JSONException e) {
      e.printStackTrace();
     }
    }
   }
  }, new Response.ErrorListener() {
   @Override
   public void onErrorResponse(VolleyError error) {
    error.printStackTrace();
   }
  });
  </code></pre>
  
  <p>And this is a piece of the JSON response:</p>
  
  <pre><code>"kind": "books#volumes",
   "totalItems": 500,
   "items": [
    {
     "kind": "books#volume",
     "id": "JUVjAgAAQBAJ",
     "etag": "kbnCYPNPKq4",
     "selfLink": "https://www.googleapis.com/books/v1/volumes/JUVjAgAAQBAJ",
     "volumeInfo": {
      "title": "Android. Podstawy tworzenia aplikacji",
      "authors": [
       "Andrzej Stasiewicz"
      ],
      "publisher": "Helion",
      "publishedDate": "2013-11-10",
      "description": "Na szczęście dostępna jest już książka Android.",
      "industryIdentifiers": [
       {
        "type": "ISBN_13",
        "identifier": "9788324688418"
       },
       {
        "type": "ISBN_10",
        "identifier": "8324688412"
       }
      ],
      "readingModes": {
       "text": true,
       "image": true
      },
      "pageCount": 216,
      "printType": "BOOK",
      "categories": [
       "Computers"
      ],
      "averageRating": 4.0,
      "ratingsCount": 1,
      "maturityRating": "NOT_MATURE",
      "allowAnonLogging": true,
      "contentVersion": "1.4.4.0.preview.3",
      "imageLinks": {
       "smallThumbnail": "http://books.google.com/books/content?id=JUVjAgAAQBAJ&amp;printsec=frontcover&amp;img=1&amp;zoom=5&amp;edge=curl&amp;source=gbs_api",
       "thumbnail": "http://books.google.com/books/content?id=JUVjAgAAQBAJ&amp;printsec=frontcover&amp;img=1&amp;zoom=1&amp;edge=curl&amp;source=gbs_api"
      }
  </code></pre>
  
  <p>And I wonder why does <code>volumeInfo.getJSONObject("imageLinks")</code> give me <code>JSONException</code> with No value for, even though the <code>imageLinks</code> has value.</p>