Here is my code
String json = "{product:{\"controls\": [[\"fire\", \"na\"], [\"jump\", \"na\"], [\"movement\", \"arrow\"]], \"languages\": [\"en\",\"br\"]}}";
XStream xstream = new XStream(new JettisonMappedXmlDriver());
xstream.alias("product", Product.class);
Product product = (Product)xstream.fromXML(json);
System.out.println(product);
But i am getting this error
Exception in thread "main" com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$DuplicateFieldException: controls
---- Debugging information ----
duplicate-field : controls
class : Product
required-type : Product
path : /product/controls[2]
line number : -1
-------------------------------
The code works for non array data.
How do I fix this?
Use annotation for arraylists class members like:
@XStreamImplicit
private List<String> content;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.