users@jersey.java.net

Re: [Jersey] Unmarshaling JAXB object from JSON

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 31 Mar 2009 13:45:46 -0400

I think if you inject an instance of Providers then you should be able
to use the getMessageBodyReader method to get a reader that will
unmarshall your JSON string.

Marc.

On Mar 31, 2009, at 12:55 PM, Farrukh Najmi wrote:

> Farrukh Najmi wrote:
>> Paul Sandoz wrote:
>>>
>>> On Mar 31, 2009, at 5:48 PM, Farrukh Najmi wrote:
>>>
>>>> Paul Sandoz wrote:
>>>>>
>>>>> On Mar 31, 2009, at 5:36 PM, Farrukh Najmi wrote:
>>>>>
>>>>>>
>>>>>> Hi Paul,
>>>>>>
>>>>>> In an earlier email you had mentioned that jersey can unmarshal
>>>>>> a JAXB object from a JSON object.
>>>>>> My jersey client sends a POST message with JSON string as value
>>>>>> for a form parameter. How can I
>>>>>> take that JSON string and unmarshal it to a JAXB object. I
>>>>>> would be grateful for some focused tip on
>>>>>> how to do this unmarshalling manually. Thanks.
>>>>>>
>>>>>
>>>>> What is the media type of the form "multipart/form-data" or
>>>>> "application/x-www-form-urlencoded" ?
>>>>>
>>>>
>>>> I am not sure as I am using a 3rd party toolkit. How can I get
>>>> this info from debugging the jersey server side code?
>>>>
>>>
>>> Add a logging filter:
>>>
>>> https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0.2/api/jersey/com/sun/jersey/api/container/filter/LoggingFilter.html
>>>
>>
>> LoggingFilter shows that mediatype is: application/x-www-form-
>> urlencoded
>
> Resending with annotation on method.
>
> Just to be clear. I have the following code:
>
> @Path("/update")
> @POST
> @Produces({"application/xml","application/json"})
> public Response update(@QueryParam("format") String format,
> MultivaluedMap<String, String> formParamsMulti) {
>
> Map formParamsMap =
> convertMultiToSingleValueMap(formParamsMulti);
>
> String postalAddresses = (String)
> formParamsMap.get("PostalAddress");
>
> }
>
> postalAddresses contains a JSON String. I have a JAXB generated class
> for PostalAddress and need to know how to unmarshal a PostalAddress
> object from the JSON String. Thanks.
>
> --
> Regards,
> Farrukh
>
> Web: http://www.wellfleetsoftware.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>