public static Gson buildGson() {
    return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
      .enableComplexMapKeySerialization()
      .registerTypeAdapter(byte[].class, new ByteArraySerializer())
      .registerTypeAdapter(Size.class, new SizeAsBytesSerializer()).create();
  }
Provides a singleton {@link Gson} instance configured just the way we like it.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/gson/GsonFactory.java