解析這裏是我的代碼JSON數組中的Java
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
-------------------------------
代碼適用於非陣列數據。
我該如何解決這個問題?
粘貼您的產品類別。 –