Instant GSON [Instant]

This title is available as an eBook only
Instant GSON [Instant]
eBook: $14.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print & eBook also available on:
Learn in an Instant - Short, Fast, Focused
Table of Contents
Sample Chapters
  • Learn something new in an Instant! A short, fast, focused guide delivering immediate results
  • Convert JAVA Objects to JSON representation and vice versa
  • Learn about the Field Exclusion strategy
  • Write your own JSON converter

Book Details

Language : English
eBook : 60 pages
Release Date : August 2013
ISBN : 1783282037
ISBN 13 : 9781783282036
Author(s) : Sandeep Kumar Patel
Topics and Technologies : All Books, Application Development, Instant, Other, Open Source

Table of Contents

Instant GSON
  • Instant GSON
    • So, what is GSON?
    • Configuring GSON in Eclipse
      • Getting the GSON library
      • Configuring a Java project
      • Configuring a Maven project
    • Quick start – creating your first JSON in GSON
      • Step 1 – instantiating GSON
        • The default approach
        • The builder approach
        • A quick example
    • Top 12 features you need to know about
      • Java objects support
      • Serialization and deserialization
      • Pretty printing
      • Nested classes
        • Static nested class
        • Pure nested class
      • Array
      • Generic type
      • Null object support
      • Versioning support
      • No argument constructor support
      • Field naming support
        • User-defined field naming
      • Field exclusion strategies
        • Configuring GsonBuilder
        • Using annotation
        • User-defined field exclusion annotation
    • Applications of GSON
    • People and places you should get to know
      • Official sites
      • Articles and tutorials
      • Community
      • Blogs

Sandeep Kumar Patel

Sandeep Kumar Patel is a senior web developer and the founder of, a widely-read programming blog since 2012. He has more than 4 years of experience in object-oriented JavaScript and JSON-based web application development. He is GATE 2005 Information Technology (IT) qualified and has a Master's degree from VIT University, Vellore. At present, he holds the position of Web Developer in SAP Labs, India. You can find out more about him from his LinkedIn profile ( He has received the DZone Most Valuable Blogger (MVB) award for technical publications related to web technologies. His article can be viewed at He has also received the Java Code Geek (JCG) badge for a technical article published in JCG. His article can be viewed at

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 1 submitted: last submission 19 May 2014

Type: Code | Page: 16 | Date: October 22, 2013


Under the code that tests the custom serializer and deserializer, there's a line of code missing after

gsonBuilder.registerTypeAdapter(Student.class, new 


The line of code is:

gsonBuilder.registerTypeAdapter(Student.class, new StudentTypeDeserializer());

Sorry, there are currently no downloads available for this title.

Frequently bought together

Instant GSON [Instant] +    Boost C++ Application Development Cookbook =
50% Off
the second eBook
Price for both: $33.00

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Convert Java objects to and from JSON
  • Handle generic and null java objects
  • Maintain different versions of serialized JSON
  • Alter the name of fields when serializing
  • Creating user defined annotation to remove fields while serializing
  • Learn about the implementation of GSON in web applications

In Detail

GSON is a specialized Java-based library for handling JSON data, developed by Google. GSON demonstrates an efficient use of CPU time, memory efficiency, the library, and developer productivity. This book will help you implement GSON in your Java project.

Instant GSON is a practical, hands-on guide that provides you with all the implementation features of the GSON API through coded examples, which will help you take advantage of the real power that is behind the GSON API, and give you a good grounding to use it in your projects.

Instant GSON starts with an introduction to the JSON data format and GSON library. It will take you through the configuration steps required to set up a GSON-based Java project. You will learn about the top features of the GSON library, which includes handling generic type and nested class objects in Java, implementing versioning support, exclusion strategies, and pretty printing. At the end of the book you will find some useful references to articles, blogs, and active communities.


Get to grips with a new technology, understand what it is and what it can do for you, and then get to work with the most important features and tasks. Instant GSON is a practical, hands-on guide that will explain the implementation features of the GSON API through examples with code.

Who this book is for

Instant GSON is for software developers who are new to the GSON library, and who are looking to explore it in depth. You should have some experience in Java programming and Java POJO classes.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software