The Gson library is a gift from Google to Java developers. It provides the simplest but powerful mechanism to deal with Json documents in Java. By using Gson library, you can parse JSON String to generate Java objects, serialize a Java object to create a JSON document. You can even pretty print JSON String by setting some option to the Gson class, which is the main helper class to interact with Gson library. It also provides mechanism to deal with nulls e.g. you can include null on JSON String or you can omit them. By default Gson print JSON in compact format where null fields are not exported to JSON document but null within array and list are exported.
This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here