GSON Introduction

Gson is a Java library, can be used to 'convert Java Objects into their JSON' representation or to convert a 'JSON string to an equivalent Java' object. Gson is an open-source project hosted initially at now it is moved to .

Main Goals Of Gson

  • Provides easy to use mechanisms like toString() and constructor (factory method) to 'convert Java to JSON and vice-versa'
  • Allow custom representations for objects
  • Allow objects convertion to and from JSON
  • Generates compact and readability JSON output

GSON is Google's JSON parser and generator for Java. Google developed GSON for internal use but open sourced it later. GSON is reasonably easy to use.

In this GSON tutorial I will take you through how to use GSON to parse JSON into Java objects, and serialize Java objects into JSON.

GSON contains multiple APIs to work with JSON. This tutorial covers the Gson component which parses JSON into Java objects, or generates JSON from Java objects.

Copyright © 2018-2020 TutorialToUs. All rights reserved.