java - MOXy DynamicEntity with JSON? -


i'm trying use dynamicentity unmarshal simple json, , it's totally bombing on me. docs rather sparse, possible this? i'm doing this;

jaxbcontext jaxbcontext = jaxbcontext.newinstance(dynamicentity.class); dynamicentity entity = (dynamicentity) jaxbcontext.createunmarshaller().unmarshal(entitystream); 

this straight xml docs here: https://wiki.eclipse.org/eclipselink/examples/moxy/dynamic/xmltodynamicentity

and get; caused by:

com.sun.xml.internal.bind.v2.runtime.illegalannotationsexception: 1 counts of illegalannotationexceptions org.eclipse.persistence.dynamic.dynamicentity interface, , jaxb can't handle interfaces.     problem related following location:         @ org.eclipse.persistence.dynamic.dynamicentity 

has managed work? i'm trying avoid building pojos since backend store doesnt care them anyway, want deserialize generic object , pass along. in .net i'd use dynamic i'm pretty stumped on how moxy.

in order dynamicentity, neccessary use dynamicjaxbcontext. can configured using following in jaxb.properties file:

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.dynamic.dynamicjaxbcontextfactory 

or can use dynamicjaxbcontextfactory directly.

although dynamic moxy not require java classes bindings (the pojos), need provide binding metadata when creating context. can xsd or binding.xml describes mapping. instead of creating context using jaxbcontext.newinstance(dynamicentity.class), need use alternative methods - see links below.

see example here (using xsd): https://wiki.eclipse.org/eclipselink/examples/moxy/dynamic/jaxbcontextfromxmlschema

or more complex example using binding.xml , json: https://wiki.eclipse.org/eclipselink/examples/moxy/dynamic/flickr


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -