com.thoughtworks.xstream.converters.ConversionExcepti

XStream xstream = new XStream(new JettisonMappedXmlDriver());
xstream.alias("teachers", List.class);
String json =
"{'teachers': [ {'id': 1, 'name': 'Rose'}, { 'id': 3, 'name': 'Tony' } ]}";
System.out.println(xstream.fromXML(json));


上面的代码报告一个错误:



Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: id : id : id : id
---- Debugging information ----
message             : id : id
cause-exception     : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message       : id : id
class               : java.util.ArrayList
required-type       : java.util.ArrayList
path                : /teachers/teachers/id
line number         : -1
-------------------------------
at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:88)
at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:55)


请各位大大帮帮我解决解决。谢谢了。

你可能感兴趣的:(java,json,xstream)