users@jersey.java.net

Re: [Jersey] Consume JSON REST Web Services using Jersey

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 29 May 2009 14:42:21 -0700

Hi Ronak,

You can use JAXB if you wish, but you can also use other types like
JSONObject or JSONArray.

Or you could use the support provided by Jackson:

http://jackson.codehaus.org/Download

It really depends on how you want to process the JSON.

Paul.

On May 29, 2009, at 2:28 PM, Ronak Patel wrote:

> All,
>
>
> How can I use Jersey to consume JSON REST Web Services?
>
>
> Can the below code be used to consume JSON services? Is the Entity
> supposed to be a JAXB annotated bean?
>
>
> final WebResource resource = Client.create().resource("http://localhost/serviceurl
> ");
>
> final Builder resourceBuilder =
> resource
> .queryParams(queryParams).accept(MediaType.APPLICATION_JSON_TYPE);
>
>
> final ClientResponse response =
> resourceBuilder.get(ClientResponse.class);
>
> response.getEntity(...);
>
>
> Ronak
>
>
>