Java EE 7 SDK |
This sample demonstrates how to use the Java API for JSON Processing with JAX-RS.
This sample shows a JAX-RS application that produces and consumes JSON
using the Java API for JSON Processing.
The JAX-RS resources in this sample can use JsonObject
, JsonArray
,
and JsonStructure
objects as method parameters and return types.
This sample demonstrates the following key features:
JsonParser
and JsonGenerator
interfaces.JsonObject
, JsonArray
, and JsonStrucuture
objects.Perform the following steps to build, deploy, and run the application:
app_dir
is the sample application base directory: samples_install_dir/jsonp/jaxrs
.run
outcome.
mvn clean verify cargo:run
http://localhost:8080/jsonp-jaxrs-resources/parser
JsonParser
interface to parse Twitter search results.
Since it needs to contact the Twitter search URL, you may need to specify the appropiate proxy
server in the Glassfish Server Administration Console.http://localhost:8080/jsonp-jaxrs-resources/generator
JsonGenerator
interface to generate sample JSON.http://localhost:8080/jsonp-jaxrs-resources/object
JsonObject
to produce and consume JSON.http://localhost:8080/jsonp-jaxrs-resources/array
JsonArray
to produce and consume JSON.http://localhost:8080/jsonp-jaxrs-resources/structure
JsonStructure
to produce and consume JSON.clean
outcome to undeploy the sample application and to remove the temporary directories such as build
and dist
.
mvn clean
If you have problems when running the application, refer to the troubleshooting document.
Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.