Java Platform, Enterprise Edition (Java EE) 8
The Java EE Tutorial
This section describes how to build and run the
application. This example is a web application that demonstrates how to
serialize an object to JSON and how to deserialize JSON to an
jsonbbasics example application is in the
The following topics are addressed here:
jsonbbasics example application contains the following files.
Two JavaServer Faces pages.
index.xhtml page contains a form to collect data that is used to
jsongenerated.xhtml page contains a text area that displays the data
in JSON format.
jsonbBean.java managed bean, which is a session-scoped
managed bean that stores the data from the form and directs the
navigation between the Facelets pages. This file contains code that
uses the JSON Binding API.
This section describes how to run the
jsonbbasics example application
from the command line using Maven.
To run the jsonbbasics example application using Maven:
Make sure that GlassFish Server has been started (see Starting and Stopping GlassFish Server).
In a terminal window, go to:
Enter the following command to deploy the application:
Open a web browser window and enter the following address:
Enter data on form and click Serialize to JSON to submit the form. The following page shows the JSON format of the object data.
Click Deserialize JSON. The index page displays and contains the fields populated from the object data.