I need to create a JSON Object for an Arraylist. Below is the code
public boolean submitOrder(ArrayList orderList) {
serUri
Your JSONObject json = new JSONObject();
should be within the loop.
Additionally, you should not do a get(i) each time to access properties (for performance). You can use the other construct of the for loop:
for (OrderDetailsData data : orderList) {
JSONObject json = new JSONObject();
json.put("orderno", data.getOrderNumber().toString());
// ...
}
Finally, maybe you should consider having a function that reads/writes a JSON object from an OrderDetailsData so that you can reuse the code in other webservices.