title: How to get data from JSONArray
body: <p>I am new to android programming and I'm trying to get data from this JSON</p>
  
  <pre><code>{
    "user": {
      "username": "justin",
      "private": false,
      "name": "Justin Nemeth",
      "vip": true,
      "vip_ep": false,
      "ids": {
        "slug": "justin"
      },
      "gender": "male",
      "age": 32,
      "images": {
        "avatar": {
          "full": 
  "https://secure.gravatar.com/avatar/30c2f0dfbc39e48656f40498aa871e33?r=pg&amp;s=256"
        }
      }
  }
  </code></pre>
  
  <p>All I need to get is the <code>"username"</code> and <code>"full"</code></p>
  
  <p>I tried using <code>jsonObject.getString("username")</code>, but it did not work and I did more research and I found that I should use <code>JSONArray</code> instead, but I tried it and it still did not work for me. I know I'm doing something wrong but I can't tell what it is.</p>
  
  <p>Here's my code</p>
  
  <pre><code>final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(
              Request.Method.GET,
              userDetailsUri,
              null,
              new Response.Listener&lt;JSONObject&gt;() {
                  @Override
                  public void onResponse(JSONObject response) {
  
                      try {
  
                          JSONObject mainObject = new JSONObject(response);
                          JSONArray resArray = mainObject.getJSONArray("user");
  
                          for (int i = 0; i &lt; resArray.length(); i++) {
  
                              JSONObject jsonObject = resArray.getJSONObject(i);
  
                              UserDetails userDetails = new UserDetails();
                              userDetails.setUsername(jsonObject.getString("username"));
                              userDetails.setProfile_image(jsonObject.getString("full"));
  
                          }
  
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                  }
              },
              new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      Log.i("vkv", "getUserDetails() " + error.toString());
                  }
              })
      {
          @Override
          public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
  
              Map&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
              headers.put("Content-Type", "application/json");
              headers.put("Authorization", "Bearer " + access_token);
              headers.put("trakt-api-version", "2");
              headers.put("trakt-api-key", client_id);
              return headers;
          }
      };
      requestQueue.add(jsonObjectRequest);
  </code></pre>