> -----Original Message----- > From: Sergey Beryozkin [mailto:[email protected]] > Sent: Tuesday, April 26, 2011 9:20 AM > To: [email protected] > Subject: Re: Unmarshalling JSON to Java fails, even though > corresponding XML works fine > > Do you use Jackson or default Jettison provider ?
Jackson. Will this be a significant problem? It's been a while since I've looked at this difference, so I don't remember why I went with Jackson, as opposed to Jettison. I can't change this right now, as I'm on the edge of a release, but I'll look into changing back to Jettison for the next release, if you think that will make a difference. > On Tue, Apr 26, 2011 at 5:02 PM, KARR, DAVID (ATTSI) <[email protected]> > wrote: > > I'm returning an instance of the following paraphrased class from my > handler method: > > > > @XmlType(name = "activeThings", propOrder = {"things"}) > > @XmlRootElement(name = "activeThings") > > public class GetActiveThingsResponse extends ResponseBase { > > @XmlElementWrapper(name = "things") > > @XmlElement(name = "thing") > > private List<Thing> things; > > > > Where "ResponseBase" looks like this: > > > > @XmlType(name = "responseBase") > > public class ResponseBase { > > @XmlElementWrapper(name = "errors") > > @XmlElement(name = "error") > > private List<Error> errors; > > private boolean lastBlock; > > > > When this is rendered as XML, it looks like this: > > > > <activeThings > xmlns="namespace"><lastBlock>false</lastBlock><things><thing><id>1</id> > </thing></things></activeThings> > > > > This is fine. > > > > When it's rendered as JSON, it looks like this: > > > > > {"things":[{"id":1,"longDescription":null,"displayName":null,"descripti > on":null}],"errors":[],"lastBlock":false} > > > > This looks reasonable, but when WebClient tries to "get" the object > of this type, it fails with this: > > > > Apr 26, 2011 8:48:05 AM > org.apache.cxf.jaxrs.provider.AbstractJAXBProvider handleJAXBException > > WARNING: javax.xml.bind.UnmarshalException > > - with linked exception: > > [javax.xml.bind.UnmarshalException: unexpected element (uri:"", > local:"things"). Expected elements are <{namespace}activeThings>] > > > > This is happening in my unit tests, not in my core code, but it's > still preventing me from testing some aspects of the JSON rendering. > >
