Skip to content

Instantly share code, notes, and snippets.

@ajduke
Created August 12, 2013 16:02
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/6212273 to your computer and use it in GitHub Desktop.
Save ajduke/6212273 to your computer and use it in GitHub Desktop.
Gson gson = new Gson();
System.out.println("Default behaviour ");
GsonBuilder gsonBuilder = new GsonBuilder();
Gson prettyGson = gsonBuilder.setPrettyPrinting().create();
String json = prettyGson.toJson(new Developer());
System.out.println(json);
System.out.println("Including the nulls ");
Gson includeNullsGson = gsonBuilder.serializeNulls().create();
String json2 = includeNullsGson.toJson(new Developer());
System.out.println(json2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment