I have this simple java object
public class Order {
static public class Product {
public String name;
public Integer quantity;
public Float price;
}
public String clientName;
public String clientPhone;
ArrayList<Product> products = new ArrayList<Product>();
public Float total;
}
I want to serialize it to JSON using Jackson. I do like this:
String _json;
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
_json = ow.writeValueAsString(order);
but it won't serialie the array list in my order, only the other members.
How do I serialize an object that contains an ArrayList
? If it's not possible is there another container class that I can use which is easy to serialize?