title: How to send arraylist of objects as parameter to a json array containing different fields using volley to a url in android?
body: <p><a href="https://i.stack.imgur.com/v53c5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v53c5.png" alt="enter image description here"></a></p>
  
  <p><strong>The JSON array in postman containing product_id, unit_price and quantity shown in the picture.</strong></p>
  
  <p>I am getting a problem with posting ArrayList of objects as a parameter to properly populate the values against the respective fields mentioned in JSON array. Please anyone who can solve my problem?
  <a href="https://i.stack.imgur.com/UrEX6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UrEX6.png" alt="enter image description here"></a></p>
  
  <p><strong>Below is my java code:</strong>
  public void placeOrder(final ArrayList productArrayList) {</p>
  
  <pre><code>    btnPlaceOrder.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              String urlPlaceOrder = "http://radial-energy.com/radial/api/place-order";
  
              StringRequest stringRequest = new StringRequest(Request.Method.POST, urlPlaceOrder,
                      new Response.Listener&lt;String&gt;() {
                          @Override
                          public void onResponse(String response) {
                              Toast.makeText(OrderDetails.this, "Response: " + response, Toast.LENGTH_SHORT).show();
  
                              JSONObject jsonObjectResponse;
  
                              try {
                                  jsonObjectResponse = new JSONObject(response);
  
                                  boolean status = jsonObjectResponse.getBoolean("success");
  
                                  if (status) {
  
                              Toast.makeText(OrderDetails.this, "Order placed successfully!", Toast.LENGTH_SHORT).show();
  
                                      Intent placeOrderIntent = new Intent(OrderDetails.this,Home.class);
                                      startActivity(placeOrderIntent);
  
                                  } else {
                                      Toast.makeText(OrderDetails.this, "Nothing!", Toast.LENGTH_SHORT).show();
                                  }
                              } catch (JSONException e) {
                                  e.printStackTrace();
                              }
                          }
                      },
                      new Response.ErrorListener() {
                          @Override
                          public void onErrorResponse(VolleyError error) {
  
                              Toast.makeText(OrderDetails.this, error.getMessage(),
                                      Toast.LENGTH_SHORT).show();
                          }
                      }) {
                  @Override
                  protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
  
                      Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
  
                      params.put("user_id", getUserId() + "");
                      params.put("distributor_id", 1 + "");
  
                      for (int i = 0; i &lt; productArrayList.size(); i++) {
                          params.put("items", productArrayList.get(i).
                      }
  
                      params.put("total", totalPriceSum + "");
                      params.put("mechanic_id", 2 + "");
  
                      return params;
                  }
              };
  
              Volley.newRequestQueue(OrderDetails.this).add(stringRequest);
  
          }
      });
  }
  </code></pre>