java - JAXB, how to skip class tag when included -
i'm trying xml:
<person> <foo>thing</foo> <bar>other</bar> </person>
from code
public class person { private innerthing in; } public class innerthing { private string foo; private string bar; }
with jaxb java annotations.
by default, get
<person> <innerthing> <foo>thing</foo> <bar>other</bar> </innerthing> </person>
how can skip innerthing tag annotations?
you use eclipselink jaxb (moxy)'s @xmlpath annotation solve problem (i'm moxy tech lead):
import javax.xml.bind.annotation.xmlaccesstype; import javax.xml.bind.annotation.xmlaccessortype; import javax.xml.bind.annotation.xmlrootelement; import org.eclipse.persistence.oxm.annotations.xmlpath; @xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class person { @xmlpath(".") private innerthing in; }
for more information:
Comments
Post a Comment