Created
February 1, 2018 22:03
-
-
Save ashwinrs/84627536f2a74dc900228e8da4ce7800 to your computer and use it in GitHub Desktop.
Pretty Print a JSON in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gson gson = new GsonBuilder().setPrettyPrinting().create(); | |
JsonParser jp = new JsonParser(); | |
JsonElement je = jp.parse(GSON.toJson(<Object>)); | |
String prettyJsonString = gson.toJson(je); | |
System.out.println(prettyJsonString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment