Skip to content

Instantly share code, notes, and snippets.

Created Aug 12, 2013
What would you like to do?
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("Ignoring/excluding fields ");
GsonBuilder excludeFieldsWithModifiers = gsonBuilder
Gson create = excludeFieldsWithModifiers.create();
String json2 = create.toJson(new Developer());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment