0

这是我的代码

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);

但我收到了这个错误

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
-------------------------------

该代码适用于非数组数据。

我该如何解决?

4

1 回答 1

0

对 arraylists 类成员使用注释,例如:

@XStreamImplicit
private List<String> content;
于 2012-12-28T09:43:32.693 回答