tree: 0c1e80636835beaedfd5ea3821e7e2fa2da78758 [path history] [tgz]
  1. src/
  2. pom.xml
  3. README.MD
examples/json-jettison/README.MD

Jettison JAX-RS JSON Provider Example

This example demonstrates how to use JSON representation of JAXB based resources with Jettison JSON provider.

A simple web application is presented with two resources: a flight list and a aircraft type list. A client can obtain the former list or update it using XML or JSON representation. The second list is read-only and shows how to provide JSON array using List<JAXBBean> objects.

Contents

The flight list web resource is implemented by org.glassfish.jersey.examples.jettison.FlightList class.

The aircraft type list web resource is implemented by org.glassfish.jersey.examples.jettison.AircraftTypeList class.

The mapping of the URI path space is presented in the following table:

URI pathResource classHTTP method
/flightsFlightListGET, PUT
/aircraftsAircraftTypeListGET

Running the Example

Run the example as follows:

mvn clean compile exec:java

This deploys the JSON from JAXB example using Grizzly

A WADL description may be accessed at the URL:

Following steps are using cURL command line tool:

Get the list of flights in JSON format:

curl -HAccept:application/json http://localhost:8080/jettison/flights

Get the list of flights in XML format:

curl -HAccept:application/xml http://localhost:8080/jettison/flights

Get the list of aircraft types in JSON format:

curl -HAccept:application/json http://localhost:8080/jettison/aircrafts

You can also see test classes at src/main/test subdirectory for detail information how to consume the service using JAX-RS client API