Skip to content

Instantly share code, notes, and snippets.

@ajduke
Last active December 20, 2015 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajduke/6210926 to your computer and use it in GitHub Desktop.
Save ajduke/6210926 to your computer and use it in GitHub Desktop.
Gson gson = new Gson();
String json = gson.toJson(new Developer());
System.out.println("********* Compact mode ***********");
System.out.println(json);
GsonBuilder gsonBuilder = new GsonBuilder();
Gson prettyGson = gsonBuilder.setPrettyPrinting().create();
json = prettyGson.toJson(new Developer());
System.out.println("\n ******* Pretty formatting *********");
System.out.println(json);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment