Java: How to print object as JSON


Sometimes, for example for debugging purposes, you need to print an object as a beatified JSON. This short post describes how to do this.

Here we use GSON library from Google. And the output will be JSON representing your object also shown with proper indentions.

Leave a Reply

Your email address will not be published. Required fields are marked *