Skip to content

Latest commit

 

History

History

json-jettison

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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 path Resource class HTTP method
/flights FlightList GET, PUT
/aircrafts AircraftTypeList GET

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