Use this builder to construct a {@link Gson} instance when you need to set configurationoptions other than the default. For {@link Gson} with default configuration, it is simpler touse {@code new Gson()}. {@code GsonBuilder} is best used by creating it, and then invoking itsvarious configuration methods, and finally calling create.
The following is an example shows how to use the {@code GsonBuilder} to construct a Gsoninstance:
Gson gson = new GsonBuilder() .registerTypeAdapter(Id.class, new IdTypeAdapter()) .serializeNulls() .setDateFormat(DateFormat.LONG) .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE) .setPrettyPrinting() .setVersion(1.0) .create();
NOTE: the order of invocation of configuration methods does not matter.
@author Inderjeet Singh @author Joel Leitch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|