我正在嘗試使用DynamicEntity解組一些簡單的JSON,並且它完全在我身上轟炸。文檔相當稀少,甚至可以做到這一點?我基本上是這樣做的;帶JSON的MOXy DynamicEntity?
JAXBContext jaxbContext = JAXBContext.newInstance(DynamicEntity.class);
DynamicEntity entity = (DynamicEntity) jaxbContext.createUnmarshaller().unmarshal(entityStream);
這是直接從XML文檔在這裏:https://wiki.eclipse.org/EclipseLink/Examples/MOXy/Dynamic/XmlToDynamicEntity
我也得到; 產生的原因:
com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.eclipse.persistence.dynamic.DynamicEntity is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at org.eclipse.persistence.dynamic.DynamicEntity
有沒有人成功地得到這個工作?我基本上試圖避免構建POJO,因爲我的後端存儲不管它們,我只是想反序列化爲一個通用對象並傳遞給它。在.NET中,我只是使用dynamic
,但我非常難以理解如何使用Moxy做到這一點。