Book Image

RESTful Java Web Services, Second Edition

Book Image

RESTful Java Web Services, Second Edition

Overview of this book

Table of Contents (17 chapters)
RESTful Java Web Services Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Using the Gson API for processing JSON


Gson is an open source Java library that can be used for converting Java objects into JSON representations and vice versa. The Gson library was originally developed by Google for its internal use and later open sourced under the terms of Apache License 2.0.

Tip

To find out the dependencies of Gson APIs, refer to https://sites.google.com/site/gson/gson-user-guide/using-gson-with-maven2.

Processing JSON with object model APIs in Gson

The main class in the Gson library that you will use for building an object model from the JSON data is the com.google.gson.Gson class. Here is a list of the core Gson classes from the object model API category:

Class

Description

com.google.gson.GsonBuilder

This class is useful when you need to construct a Gson instance, overriding the default configurations such as custom date format, pretty printing, and custom sterilization.

com.google.gson.Gson

This class is the main class for using Gson. This class does the conversion...