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.
Object to JSON
If we need a human-readable json we can enable “pretty printing”
You may also find these posts interesting: