users@jersey.java.net

Re: [Jersey] Unmarshaling JAXB object from JSON

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 01 Apr 2009 14:06:14 +0200

On Apr 1, 2009, at 1:57 PM, Farrukh Najmi wrote:
> Hi Paul,
>
> If the jsonString represents List<PostalAddressType> where
> PostalAddressType is my JAXB generated bean then what should c be
> and how can I create an instance. Sorry for asking such a basic
> question. Also I note that the second arg to getMessageBodyReader is
> of a different type. I can get that with following code (thanks Marc):
>
> GenericEntity<List<PostalAddressType>> entityPostalAddresses =
> new
> GenericEntity<List<PostalAddressType>>(listPostalAddresses) {};
> Type genericTypePostalAddresses = entityPostalAddresses.getType();
>
> So my call looks like:
>
> providers.getMessageBodyReader(??, genericTypePostalAddresses,
> (java.lang.annotation.Annotation[])null, "application/json");
>
> and I am unsure how to get the first param in the call.
>

?? = entityPostalAddresses.getRawType();

or

  List.class

Do not pass null for the annotation array use an empty array:

   new Annotation[0]

Paul.