users@jersey.java.net

Re: [Jersey] Jaxb/Json and XmlElementRef

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Wed, 1 Sep 2010 11:51:07 +0200

Hi Johannes,

I am guessing there are some underlying constraints with the default,
mapped or badgerFish configuration. Jakub, who is currently on
holiday, may know more.

To switch to the natural convention see here:

   https://jersey.dev.java.net/nonav/documentation/latest/user-guide.html
#d4e815

Paul.

On Aug 31, 2010, at 11:53 AM, Johannes Schneider wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi guys,
>
> I don't know whether this is the right list to ask (probably not)...
> But
> since Jersey provides the glue code...
>
> I have a XML root element with that declaration:
>
> @XmlElementRef
> private List<Stub> users;
>
>
> The XML looks fine - just as I expected.
> Serializing this to JSON:
>
> {"user":[
> {
> ....
>
>
> Well, the "user" isn't too nice (I think this is the name as added to
> the XmlType of the bean contained into the list)
>
> The problem is, that unmarshalling does *not* work. the collection is
> null...
>
>
> I tried to investigate the problem and found out that:
>
> - - Unmarshalling only works as expected with "natural" as
> configuration:
>
> JSONJAXBContext context = new JSONJAXBContext(
> JSONConfiguration.natural().build(),..)
> JSONMarshaller marshaller = context.createJSONMarshaller();
>
> - - It does *not* work with the default, mapped or badgerFish
> configuration.
>
>
> So could anybody give me a hint, what my problem is? Or is this a
> missing feature from the underlying JSON library?
> How can I configure the JSON configuration with Jetty? So that I could
> simply switch to natural...
>
>
>
> Thanks,
>
> Johannes
>
> - --
> Johannes Schneider - blog.cedarsoft.com
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
>
> iQEcBAEBAgAGBQJMfNEdAAoJEAytD9R7Qv6d37cH/1kWI/y6F/LKAAb+rlfnqYtI
> Y7EXMIluZbtzdCRq9pEmFAwcLQpWtAEWTBCt9dZo5ukeS4NFuPer5UBvya3WA/K6
> cOVHcVXLQBxv8SbZOJuO0EzjdgsVYLwRFsVb96QfwPRVzDKJsjFzcUHjJVVfxlzN
> Pf/NBsD84WK0TdpargOjI3lIm9s/zc6/ysM7dLgSP9tJUuL+TfC+4GoabEfS40VV
> PJzWzLQWvGnH4Zc3hAQSQ9CmZZRBEkUDBgLjplWMFL/gFvyfyXJ7ta3Sl+yIoEqI
> tkoAknuyEKAiGp4YKODJmdr0CkeksQ5n3J3KunWHyavfMGFn3kwH812o6cFPkU4=
> =g4JL
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>