json - JAXBContext handling of @XmlValue -
i've come across problem in code: when fields except 1 declared @xmlvalue
null, moxy marshals out field if sole value of whole object. realize may purposeful implementation i'm wondering if there's workaround it. note: i'm using eclipselink moxy, seems standard jaxb bindings
@xmlrootelement @xmlaccessortype(xmlaccesstype.field) public class foo { @xmlvalue private final string name; @xmlattribute(name = "name2", required = true) private final string name2; >....getters, setters, etc....< public foo(string name, string name2) { this.name = name; this.name2 = name2; } }
and i'm running
jaxbcontext jc = jaxbcontext.newinstance(moxytest.foo.class); marshaller marsh = jc.createmarshaller(); marsh.setproperty(marshaller.jaxb_formatted_output, true); marsh.setproperty("eclipselink.media-type", "application/json"); stringwriter strwriter = new stringwriter(); foo example = new foo("blah", null); marsh.marshal(example, strwriter);
i want output be
{ "foo" : { value: "blah" } }
but instead due @xmlvalue
annotation it's
{ "foo" : "blah" }
update
this issue has been fixed in eclipselink 2.5.1 , 2.6.0 streams. can download nightly build containing fix following link starting august 8, 2013.
original answer
i have opened following bug issue. can use track our progress.
Comments
Post a Comment