users@jersey.java.net

[Jersey] JSON Processing Using the New Client API

From: <reza.rahman_at_oracle.com>
Date: Tue, 26 Feb 2013 01:44:48 +0000 (GMT)

I am having a bi of trouble with the new API. Here is my server-side
code:

@GET
@Path("/shortest-path")
@Produces(MediaType.APPLICATION_JSON)
public List<TransitPath> findShortestPath(
    @QueryParam("origin")
    final String originUnLocode,
    @QueryParam("destination")
    final String destinationUnLocode,
    @QueryParam("deadline")
    final String deadline) {

I've also setup JSON parsing in web.xml:

<init-param>
  <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
  <param-value>true</param-value>
</init-param>

What is would be the correct corresponding code on the client? What
providers/configuration do I need? Here's what I have (which clearly
could not work):

final List<TransitPath> transitPaths = graphTraversalResource
    .queryParam("origin", origin)
    .queryParam("destination", destination)
    .request(MediaType.APPLICATION_JSON)
    .get(new GenericType<List<TransitPath>>() {});

Is the list type correct?

Thanks in advance.