次のような rootElement の名前を持たない JSON データがあります。
{
name: "Anthony",
source: "DS"
}
アンマーシャリング用に次のようなJavaクラスがあります。
@XmlRootElement
@XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
@XmlAccessorType(XmlAccessType.PUBLIC_MEMBER)
public class ObjectTest {
private String name;
private String source;
/* with Getter & Setter for "name" & "source" */
}
アンマーシャリング コード:
JAXBContext jc = JettisonMappedContext.newInstance(ObjectTest.class);
MappedNamespaceConvention c = new MappedNamespaceConvention();
JettisonMappedMarshaller u= new JettisonMappedMarshaller(jc, c);
String text = "{name: \"Anthony\", source: \"DS\"}";
u.unmarshal(new StringReader(text));
例外:
[javax.xml.bind.UnmarshalException: unexpected element (uri:"", local:"name"). Expected elements are <{}objectTest>]
上記の内容に基づいてアンマーシャリングを行うにはどうすればよいですか? ありがとう
resteasy バージョン: 1.1 RC2