assertEquals(json, xstream.toXML(list2));
}
public void testListWithComplexNestedObjects() {
ArrayList list1 = new ArrayList();
list1.add(new Product("Banana", "123", 23.00));
list1.add(new Product("Apple", "47", 11.00));
list1.add(new Product("Orange", "100", 42.00));
ArrayList tags = new ArrayList();
((Product)list1.get(1)).setTags(tags);
tags.add(new Product("Braeburn", "47.1", 10.00));
String json = xstream.toXML(list1);
assertEquals(
(JVM.is15()
? "{'list':[{'product':[{'name':'Banana','id':123,'price':23},{'name':'Apple','id':47,'price':11,'tags':[{'product':{'name':'Braeburn','id':47.1,'price':10}}]},{'name':'Orange','id':100,'price':42}]}]}"
: "{'list':{'product':[{'name':'Banana','id':123,'price':23},{'name':'Apple','id':47,'price':11,'tags':{'product':[{'name':'Braeburn','id':47.1,'price':10}]}},{'name':'Orange','id':100,'price':42}]}}")