Java tutorial
//package com.java2s; import java.lang.reflect.Modifier; import com.google.gson.Gson; import com.google.gson.GsonBuilder; public class Main { public static Gson getGsonWithPrettyPrinting() { return new GsonBuilder().excludeFieldsWithModifiers(new int[] { Modifier.STATIC, Modifier.TRANSIENT //, Modifier.FINAL }).excludeFieldsWithoutExposeAnnotation().setPrettyPrinting().create(); } }