JSON (JavaScript Object Notation) is the most popular data format used for web client/server communications.
Gson is the easiest way to convert a string in JSON format to Java Object and Java Object to a string in JSON format.
GSON. Maven Dependency
JSON to object with Gson
Let’s assume we have some String json. This contains JSON formatted MyClass object. We want to convert this json string to the object of MyClass.
That’s it.
Object to JSON
If we need a human-readable json we can enable “pretty printing”
You may also find these posts interesting: