title: Get JSON with Volley
body: <p>I want to get this JSON in Android with Volley. How can I do that?</p>
  
  <pre><code>{ "post": [ { "title": "a", "content": "a", "mobile": "a", "imageurl": "a" }, { "title": "b", "content": "b", "mobile": "b", "imageurl": "b" } ], "banner": [ { "title": "c", "content": "c", "mobile": "c", "imageurl": "c" }, { "title": "d", "content": "d", "mobile": "d", "imageurl": "d" } ] }
  </code></pre>
  
  <p>This is my code in Java:</p>
  
  <pre><code>public void GetPost(JSONObject jsonObject, final onPostReceived onPostReceived) {
      String url = "";
      JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, url, jsonObject, new Response.Listener&lt;JSONObject&gt;() {
          @Override
          public void onResponse(JSONObject response) {
  
  
              Log.i(TAG, "onResponseGetPost: " + response.toString());
              try {
                  // iwant to get all posts and banners 
                  //for example 20 post
                  // 2 banner
  
                  List&lt;Post&gt; postList = new ArrayList&lt;&gt;();
                  List&lt;PostBanner&gt; postBannerList = new ArrayList&lt;&gt;();
  
                  JSONArray json = response.getJSONArray("banner");
                  JSONArray jsonArray = response.getJSONArray("post");
  
                  for (int i = 0; i &lt; jsonArray.length(); i++) {
                      Post post = new Post();
                      PostBanner postBanner = new PostBanner();
  
                      JSONObject jsonObject = jsonArray.getJSONObject(i);
                      post.setImageUrl(jsonObject.getString("imageurl"));
                      post.setContent(jsonObject.getString("content"));
                      post.setTitle(jsonObject.getString("title"));
                      post.setMobile(jsonObject.getString("mobile"));
  
                      postList.add(post);
  
  
                      JSONObject jsonObject1 = json.getJSONObject(i);
                      postBanner.setTitle(jsonObject1.getString("title"));
                      postBanner.setContent(jsonObject1.getString("content"));
                      postBanner.setMobile(jsonObject1.getString("mobile"));
                      postBanner.setImageUrl(jsonObject1.getString("imageurl"));
  
                      postBannerList.add(postBanner);
                      onPostReceived.onReceived(postList, postBannerList);
                  }
  
              } catch (JSONException e) {
                  e.printStackTrace();
              }
  
  
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
           //log error
          }
      });
      request.setRetryPolicy(new DefaultRetryPolicy(18000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
      Volley.newRequestQueue(context).add(request);
  }
  </code></pre>
  
  <p>What is the problem in this code? It get posts until banner length, but just one banner when I run the app. Why?</p>