public abstract class AbstractJsonHttpMessageConverter extends AbstractGenericHttpMessageConverter<java.lang.Object>
Jackson コンバーターは、マルチフォーマットをサポートしているため、専用のクラス階層を持っていることに注意してください。
GsonHttpMessageConverter, JsonbHttpMessageConverter, readInternal(Type, Reader), writeInternal(Object, Type, Writer)| 修飾子と型 | フィールドと説明 |
|---|---|
static java.nio.charset.Charset | DEFAULT_CHARSET コンバーターが使用するデフォルトの文字セット。 |
logger| コンストラクターと説明 |
|---|
AbstractJsonHttpMessageConverter() |
| 修飾子と型 | メソッドと説明 |
|---|---|
java.lang.Object | read(java.lang.reflect.Type type, java.lang.Class<?> contextClass, HttpInputMessage inputMessage) 指定された入力メッセージから指定された型のオブジェクトを読み取り、それを返します。 |
protected java.lang.Object | readInternal(java.lang.Class<?> clazz, HttpInputMessage inputMessage) 実際のオブジェクトを読み取る抽象テンプレートメソッド。 |
protected abstract java.lang.Object | readInternal(java.lang.reflect.Type resolvedType, java.io.Reader reader) 指定された Reader から JSON バインドオブジェクトを読み取るテンプレートメソッド。 |
void | setJsonPrefix(java.lang.String jsonPrefix)JSON 出力に使用するカスタムプレフィックスを指定します。 |
void | setPrefixJson(boolean prefixJson) このビューによる JSON 出力に「)]} '、」をプレフィックスとして付けるかどうかを示します。 |
protected void | writeInternal(java.lang.Object o, java.lang.reflect.Type type, HttpOutputMessage outputMessage) 実際の本文を書き込む抽象テンプレートメソッド。 |
protected abstract void | writeInternal(java.lang.Object o, java.lang.reflect.Type type, java.io.Writer writer)JSON にバインドされたオブジェクトを指定された Writer に書き込むテンプレートメソッド。 |
canRead, canWrite, supports, write, writeInternaladdDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanRead, canWrite, getSupportedMediaTypes, read, writepublic static final java.nio.charset.Charset DEFAULT_CHARSET
public void setJsonPrefix(java.lang.String jsonPrefix)
public void setPrefixJson(boolean prefixJson)
false です。この方法で JSON 文字列のプレフィックスを使用すると、JSON ハイジャックを防ぐことができます。プレフィックスは、文字列をスクリプトとして構文的に無効にして、ハイジャックできないようにします。このプレフィックスは、文字列を JSON として解析する前に削除する必要があります。
public final java.lang.Object read(java.lang.reflect.Type type,
@Nullable
java.lang.Class<?> contextClass,
HttpInputMessage inputMessage)
throws java.io.IOException,
HttpMessageNotReadableExceptionGenericHttpMessageConvertertype - 返される(潜在的に汎用の)型のオブジェクト。この型は、このインターフェースの canRead メソッドに事前に渡されている必要があります。このメソッドは true を返している必要があります。contextClass - ターゲット型のコンテキストクラス。たとえば、ターゲット型がメソッドシグネチャーに表示されるクラス (null にすることができます)inputMessage - 読み込む HTTP 入力メッセージ java.io.IOException - I/O エラーの場合 HttpMessageNotReadableException - 変換エラーの場合 protected final java.lang.Object readInternal(java.lang.Class<?> clazz,
HttpInputMessage inputMessage)
throws java.io.IOException,
HttpMessageNotReadableExceptionAbstractHttpMessageConverterAbstractHttpMessageConverter.read(java.lang.Class<? extends T>, org.springframework.http.HttpInputMessage) から呼び出されます。AbstractHttpMessageConverter<java.lang.Object> の readInternal clazz - 返すオブジェクトの型 inputMessage - 読み込む HTTP 入力メッセージ java.io.IOException - I/O エラーの場合 HttpMessageNotReadableException - 変換エラーの場合 protected final void writeInternal(java.lang.Object o,
@Nullable
java.lang.reflect.Type type,
HttpOutputMessage outputMessage)
throws java.io.IOException,
HttpMessageNotWritableExceptionAbstractGenericHttpMessageConverterAbstractGenericHttpMessageConverter.write(T, java.lang.reflect.Type, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage) から呼び出されます。AbstractGenericHttpMessageConverter<java.lang.Object> の writeInternal o - 出力メッセージに書き込むオブジェクト type - 書き込むオブジェクトの型 (null の場合があります)outputMessage - 書き込む HTTP 出力メッセージ java.io.IOException - I/O エラーの場合 HttpMessageNotWritableException - 変換エラーの場合 protected abstract java.lang.Object readInternal(java.lang.reflect.Type resolvedType,
java.io.Reader reader)
throws java.lang.ExceptionReader から JSON バインドオブジェクトを読み取るテンプレートメソッド。resolvedType - 解決されたジェネリクス型 reader - 使用するリーダー java.lang.Exception - 読み取り / 解析の失敗の場合 protected abstract void writeInternal(java.lang.Object o,
@Nullable
java.lang.reflect.Type type,
java.io.Writer writer)
throws java.lang.ExceptionWriter に書き込むテンプレートメソッド。o - 出力メッセージに書き込むオブジェクト type - 書き込むオブジェクトの型 (null の場合があります)writer - 使用するライター java.lang.Exception - 書き込みエラーの場合