I need to create a JSON Object for an Arraylist. Below is the code
public boolean submitOrder(ArrayList orderList) {
serUri
This following snippet will create array of json objects in single statement, it even performs null checks while creating json from object using Google's Gson library.
public boolean submitOrder(ArrayList orderList) {
Gson gson = new Gson();
JsonObject myObj = new JsonObject();
JsonElement ordersObj = gson.toJsonTree(orderList);
myObj.add("list", ordersObj);
}