[英]JSON array parsing in java
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: 对arraylists类成员使用注释,例如:
@XStreamImplicit
private List<String> content;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.