Hi,
Do you have any JSON serializer in your classpath?
I am not sure if there is one provided by default in Jersey.
If you use Maven, and add the below, is it then able to produce some JSON?
<!-- High-performance JSON serializer -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-lgpl</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-lgpl</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.7</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.9.7</version>
</dependency>
Cheers,
M.
2012/6/7 Brendan cheng <ccp999_at_hotmail.com>
>
> 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
>
>