public class GsonMessageConverter extends AbstractJsonMessageConverter
MessageConverter
that can read and write JSON
using Google Gson.Gson
,
GsonBuilder
,
setGson(com.google.gson.Gson)
logger
Constructor and Description |
---|
GsonMessageConverter()
Construct a new
GsonMessageConverter with default configuration. |
GsonMessageConverter(com.google.gson.Gson gson)
Construct a new
GsonMessageConverter with the given delegate. |
Modifier and Type | Method and Description |
---|---|
protected Object |
fromJson(Reader reader,
Type resolvedType) |
protected Object |
fromJson(String payload,
Type resolvedType) |
com.google.gson.Gson |
getGson()
Return the configured
Gson instance for this converter. |
void |
setGson(com.google.gson.Gson gson)
Set the
Gson instance to use. |
protected String |
toJson(Object payload,
Type resolvedType) |
protected void |
toJson(Object payload,
Type resolvedType,
Writer writer) |
convertFromInternal, convertToInternal, supports
addSupportedMimeTypes, canConvertFrom, canConvertTo, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
public GsonMessageConverter()
GsonMessageConverter
with default configuration.public GsonMessageConverter(com.google.gson.Gson gson)
GsonMessageConverter
with the given delegate.gson
- the Gson instance to usepublic void setGson(com.google.gson.Gson gson)
Gson
instance to use.
If not set, a default Gson
instance will be used.
Setting a custom-configured Gson
is one way to take further
control of the JSON serialization process.
GsonMessageConverter(Gson)
public com.google.gson.Gson getGson()
Gson
instance for this converter.protected Object fromJson(Reader reader, Type resolvedType)
fromJson
in class AbstractJsonMessageConverter
protected Object fromJson(String payload, Type resolvedType)
fromJson
in class AbstractJsonMessageConverter
protected void toJson(Object payload, Type resolvedType, Writer writer)
toJson
in class AbstractJsonMessageConverter
protected String toJson(Object payload, Type resolvedType)
toJson
in class AbstractJsonMessageConverter