public class GsonFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<com.google.gson.Gson>, org.springframework.beans.factory.InitializingBean
FactoryBean for creating a Google Gson 2.x Gson instance.| Constructor and Description |
|---|
GsonFactoryBean() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
com.google.gson.Gson |
getObject()
Return the created Gson instance.
|
Class<?> |
getObjectType() |
boolean |
isSingleton() |
void |
registerTypeAdapterFactory(com.google.gson.TypeAdapterFactory typeAdapterFactory) |
void |
setDateFormatPattern(String dateFormatPattern)
Define the date/time format with a
SimpleDateFormat-style pattern. |
void |
setDisableHtmlEscaping(boolean disableHtmlEscaping)
Whether to use the
GsonBuilder.disableHtmlEscaping() when writing JSON. |
void |
setPrettyPrinting(boolean prettyPrinting)
Whether to use the
GsonBuilder.setPrettyPrinting() when writing JSON. |
void |
setSerializeNulls(boolean serializeNulls)
Whether to use the
GsonBuilder.serializeNulls() option when writing JSON. |
public void setSerializeNulls(boolean serializeNulls)
GsonBuilder.serializeNulls() option when writing JSON. This is a shortcut for setting
up a Gson as follows:
new GsonBuilder().serializeNulls().create();
public void setPrettyPrinting(boolean prettyPrinting)
GsonBuilder.setPrettyPrinting() when writing JSON. This is a shortcut for setting up a
Gson as follows:
new GsonBuilder().setPrettyPrinting().create();
public void setDisableHtmlEscaping(boolean disableHtmlEscaping)
GsonBuilder.disableHtmlEscaping() when writing JSON. Set to true to disable
HTML escaping in JSON. This is a shortcut for setting up a Gson as follows:
new GsonBuilder().disableHtmlEscaping().create();
public void setDateFormatPattern(String dateFormatPattern)
SimpleDateFormat-style pattern. This is a shortcut for setting up a
Gson as follows:
new GsonBuilder().setDateFormat(dateFormatPattern).create();
public void registerTypeAdapterFactory(com.google.gson.TypeAdapterFactory typeAdapterFactory)
public void afterPropertiesSet()
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanpublic com.google.gson.Gson getObject()
getObject in interface org.springframework.beans.factory.FactoryBean<com.google.gson.Gson>public Class<?> getObjectType()
getObjectType in interface org.springframework.beans.factory.FactoryBean<com.google.gson.Gson>public boolean isSingleton()
isSingleton in interface org.springframework.beans.factory.FactoryBean<com.google.gson.Gson>Copyright © 2015. All Rights Reserved.