Java — Pretty Print JSON (Gson)

Sometimes you prefer to print JSON in pretty format instead of just plain string. You can use Google’s Gson library to pretty print JSON.

Here is a complete working example with sample output:

Like what you read? Give Rasheed Amir a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.