public class GsonHttpMessageConverter extends BaseHttpMessageConverter<Object>
DEFAULT_CHARSET| Constructor and Description |
|---|
GsonHttpMessageConverter()
Construct a new
GsonHttpMessageConverter with a default Gson. |
GsonHttpMessageConverter(boolean prettyPrinting)
Construct a new
GsonHttpMessageConverter with a default Gson. |
GsonHttpMessageConverter(com.google.gson.Gson gson)
Construct a new
GsonHttpMessageConverter. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead(Class<?> clazz,
org.springframework.http.MediaType mediaType) |
boolean |
canWrite(Class<?> clazz,
org.springframework.http.MediaType mediaType) |
com.google.gson.Gson |
getGson() |
Type |
getType() |
protected Object |
readInternal(Class<?> clazz,
org.springframework.http.HttpInputMessage inputMessage) |
void |
setPrefixJson(boolean prefixJson)
Indicates whether the JSON output by this view should be prefixed with "{} &&".
|
void |
setType(Type type) |
protected boolean |
supports(Class<?> clazz) |
protected void |
writeInternal(Object o,
org.springframework.http.HttpOutputMessage outputMessage) |
getCharsetpublic GsonHttpMessageConverter()
GsonHttpMessageConverter with a default Gson.public GsonHttpMessageConverter(boolean prettyPrinting)
GsonHttpMessageConverter with a default Gson.public GsonHttpMessageConverter(com.google.gson.Gson gson)
GsonHttpMessageConverter.gson - a customized Gsonpublic void setType(Type type)
public Type getType()
public com.google.gson.Gson getGson()
public void setPrefixJson(boolean prefixJson)
Prefixing the JSON string in this manner is used to help prevent JSON Hijacking. The prefix renders the string syntactically invalid as a script so that it cannot be hijacked. This prefix does not affect the evaluation of JSON, but if JSON validation is performed on the string, the prefix would need to be ignored.
public boolean canRead(Class<?> clazz, org.springframework.http.MediaType mediaType)
public boolean canWrite(Class<?> clazz, org.springframework.http.MediaType mediaType)
protected boolean supports(Class<?> clazz)
supports in class org.springframework.http.converter.AbstractHttpMessageConverter<Object>protected Object readInternal(Class<?> clazz, org.springframework.http.HttpInputMessage inputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotReadableException
readInternal in class org.springframework.http.converter.AbstractHttpMessageConverter<Object>IOExceptionorg.springframework.http.converter.HttpMessageNotReadableExceptionprotected void writeInternal(Object o, org.springframework.http.HttpOutputMessage outputMessage) throws IOException, org.springframework.http.converter.HttpMessageNotWritableException
writeInternal in class org.springframework.http.converter.AbstractHttpMessageConverter<Object>IOExceptionorg.springframework.http.converter.HttpMessageNotWritableExceptionCopyright © 2015. All Rights Reserved.