Pretty Print JSON with JSON.simple

This article shows how to pretty print JSON with JSON.simple. Table of contents: 1. Setup JSON.simple 2. Default Compact Print JSON 3. Pretty Print JSON with JSON.simple 4. Write Pretty Print JSON to a File 5. Download Source Code 6. References P.S Tested with json-simple 4.0.1 1. Setup JSON.simple pom.xml <dependency> <groupId>com.github.cliftonlabs</groupId> <artifactId>json-simple</artifactId> <version>4.0.1</version> </dependency> …

Read more

How to pretty print JSON using Moshi

This article shows how to use Moshi’s JsonAdaptor indent method to enable the pretty print JSON. Table of contents: 1. Download Moshi 2. Compact print JSON (Default) 3. Pretty print JSON using Moshi 4. Download Source Code 5. References P.S Tested with Moshi 1.15.1 1. Download Moshi Declare moshi in the pom.xml. pom.xml <dependency> <groupId>com.squareup.moshi</groupId> …

Read more

How to enable pretty print JSON with Jackson

In Jackson, we can use writerWithDefaultPrettyPrinter() to pretty print the JSON strings. Table of contents: 1. Setup Jackson 2. Compact print JSON (Default) 3. Pretty print JSON with Jackson 4. Pretty print JSON with Jackson (Globally) 5. Download Source Code 6. References P.S Tested with Jackson 2.17.0 1. Setup Jackson Puts jackson-databind at pom.xml. pom.xml …

Read more

How to pretty print JSON using Gson

This article shows how to pretty print JSON using Gson. Table of contents: 1. Setup Google Gson 2. Default Compact Print JSON 3. Pretty Print JSON using Gson 4. Download Source Code 5. References P.S Tested with Gson 2.10.1 1. Setup Google Gson Declare gson in the pom.xml. pom.xml <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.10.1</version> </dependency> 2. …

Read more