类 AbstractJsonHttpMessageConverter
java.lang.Object
cn.taketoday.http.converter.AbstractHttpMessageConverter<T>
cn.taketoday.http.converter.AbstractGenericHttpMessageConverter<Object>
cn.taketoday.http.converter.json.AbstractJsonHttpMessageConverter
- 所有已实现的接口:
GenericHttpMessageConverter<Object>,HttpMessageConverter<Object>
public abstract class AbstractJsonHttpMessageConverter
extends AbstractGenericHttpMessageConverter<Object>
Common base class for plain JSON converters, e.g. Gson and JSON-B.
Note that the Jackson converters have a dedicated class hierarchy due to their multi-format support.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Harry Yang
- 另请参阅:
-
字段概要
字段从类继承的字段 cn.taketoday.http.converter.AbstractHttpMessageConverter
logger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private static CharsetgetCharset(HttpHeaders headers) private static ReadergetReader(HttpInputMessage inputMessage) private static WritergetWriter(HttpOutputMessage outputMessage) final Objectread(Type type, Class<?> contextClass, HttpInputMessage inputMessage) Read an object of the given type form the given input message, and returns it.protected final ObjectreadInternal(Class<?> clazz, HttpInputMessage inputMessage) Abstract template method that reads the actual object.protected abstract ObjectreadInternal(Type resolvedType, Reader reader) Template method that reads the JSON-bound object from the givenReader.private ObjectreadResolved(Type resolvedType, HttpInputMessage inputMessage) voidsetJsonPrefix(String jsonPrefix) Specify a custom prefix to use for JSON output.voidsetPrefixJson(boolean prefixJson) Indicate whether the JSON output by this view should be prefixed with ")]}', ".protected final voidwriteInternal(Object object, Type type, HttpOutputMessage outputMessage) Abstract template method that writes the actual body.protected abstract voidwriteInternal(Object object, Type type, Writer writer) Template method that writes the JSON-bound object to the givenWriter.从类继承的方法 cn.taketoday.http.converter.AbstractGenericHttpMessageConverter
canRead, canWrite, supports, write, writeInternal从类继承的方法 cn.taketoday.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.http.converter.HttpMessageConverter
canRead, canWrite, getSupportedMediaTypes, getSupportedMediaTypes, read, write
-
字段详细资料
-
jsonPrefix
-
-
构造器详细资料
-
AbstractJsonHttpMessageConverter
public AbstractJsonHttpMessageConverter()
-
-
方法详细资料
-
setJsonPrefix
Specify a custom prefix to use for JSON output. Default is none.- 另请参阅:
-
setPrefixJson
public void setPrefixJson(boolean prefixJson) Indicate whether the JSON output by this view should be prefixed with ")]}', ". Default isfalse.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 should be stripped before parsing the string as JSON.
-
read
public final Object read(Type type, @Nullable Class<?> contextClass, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException 从接口复制的说明:GenericHttpMessageConverterRead an object of the given type form the given input message, and returns it.- 参数:
type- the (potentially generic) type of object to return. This type must have previously been passed to thecanReadmethod of this interface, which must have returnedtrue.contextClass- a context class for the target type, for example a class in which the target type appears in a method signature (can benull)inputMessage- the HTTP input message to read from- 返回:
- the converted object
- 抛出:
IOException- in case of I/O errorsHttpMessageNotReadableException- in case of conversion errors
-
readInternal
protected final Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException 从类复制的说明:AbstractHttpMessageConverterAbstract template method that reads the actual object. Invoked fromAbstractHttpMessageConverter.read(java.lang.Class<? extends T>, cn.taketoday.http.HttpInputMessage).- 指定者:
readInternal在类中AbstractHttpMessageConverter<Object>- 参数:
clazz- the type of object to returninputMessage- the HTTP input message to read from- 返回:
- the converted object
- 抛出:
IOException- in case of I/O errorsHttpMessageNotReadableException- in case of conversion errors
-
readResolved
private Object readResolved(Type resolvedType, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException -
writeInternal
protected final void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException 从类复制的说明:AbstractGenericHttpMessageConverterAbstract template method that writes the actual body. Invoked fromAbstractGenericHttpMessageConverter.write(T, java.lang.reflect.Type, cn.taketoday.http.MediaType, cn.taketoday.http.HttpOutputMessage).- 指定者:
writeInternal在类中AbstractGenericHttpMessageConverter<Object>- 参数:
object- the object to write to the output messagetype- the type of object to write (may benull)outputMessage- the HTTP output message to write to- 抛出:
IOException- in case of I/O errorsHttpMessageNotWritableException- in case of conversion errors
-
readInternal
Template method that reads the JSON-bound object from the givenReader.- 参数:
resolvedType- the resolved generic typereader- the Reader to use- 返回:
- the JSON-bound object
- 抛出:
Exception- in case of read/parse failures
-
writeInternal
protected abstract void writeInternal(Object object, @Nullable Type type, Writer writer) throws Exception Template method that writes the JSON-bound object to the givenWriter.- 参数:
object- the object to write to the output messagetype- the type of object to write (may benull)writer- the Writer to use- 抛出:
Exception- in case of write failures
-
getReader
- 抛出:
IOException
-
getWriter
- 抛出:
IOException
-
getCharset
-