Android Volley如何发布自定义对象数组

I'm new to volley and i need to post an array of custom object to PHP api in order to save it in MYSQL database how can i accomplish this ?

Note : I know that my below code will pass only the last object of my array only

Here is my object :

public class object {

String name;
Integer qty;
Integer price;
}

and my code :

final ArrayList<object> myarray = new ArrayList<>();
        myarray.add(ob1);
        myarray.add(ob2);
        RequestQueue queue = Volley.newRequestQueue(this);
        JSONObject jsonArray = new JSONObject();
        try {
            int i = 0;
            for (object obj : myarray) {

                jsonArray.put("id",i++);
                jsonArray.put("name",obj.name);
                jsonArray.put("qty",obj.qty);
                jsonArray.put("price",obj.price);
            }
            Log.i("JSON ARRAY ", jsonArray.toString());

        } catch (Exception e) {
            e.printStackTrace();
        }
        JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, API_URL, jsonArray, new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(JSONObject response) {
                Log.i("RESPONSE",response.toString());
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
            }
        }){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                HashMap<String, String> params = new HashMap<>();
                return params;
            }
        }; queue.add(request);
    }

Need to add your JSONObject to JSONArray for every loop like,

JSONArray jsonArray = new JSONArray();

int i = 0;
  for (object obj : myarray) {
     JSONObject jsonObj= new JSONObject();
     jsonObj.put("id", i++);
     jsonObj.put("name", nameStr);
     jsonObj.put("qty", qtyStr);
     jsonObj.put("price", priceStr);

     jsonArray.put(jsonObj);

}

Log.i("JSON ARRAY ", jsonArray.toString());

this may helps you.