users@jersey.java.net

[Jersey] Re: how to use Application/Json in JResponse

From: Martin Matula <martin.matula_at_oracle.com>
Date: Mon, 11 Jun 2012 15:20:07 +0200

If you need JAXB->JSON mapping, you need to add jersey-json jar to your classpath.
Martin

On Jun 7, 2012, at 9:44 AM, Brendan cheng wrote:

>
> Hi,
> my following function in Resource file can produce result correctly in xml but not JSON.
> @GET
> @Path("/{id}/companies")
> @Produces({ "application/xml", "application/json" })
> public JResponse<List<hk.itags.restclient.Company>> getCompanies(
> @PathParam(value = "id") long id) {
> List<hk.itags.restclient.Company> comlist = null; .... return JResponse.ok(comlist).build(); }
> I thought JAXB can produce both xml and json output. what is the problem?
> Regards,
> Brendan
>
>