Class Jackson2JsonEncoder
java.lang.Object
org.springframework.http.codec.json.Jackson2CodecSupport
org.springframework.http.codec.json.AbstractJackson2Encoder
org.springframework.http.codec.json.Jackson2JsonEncoder
- All Implemented Interfaces:
Encoder<Object>
,HttpMessageEncoder<Object>
Encode from an
Object
stream to a byte stream of JSON objects using Jackson 2.x.
For non-streaming use cases, Flux
elements are collected into a List
before serialization for performance reason.- Since:
- 5.0
- Author:
- Sebastien Deleuze, Arjen Poutsma
- See Also:
-
Field Summary
Fields inherited from class org.springframework.http.codec.json.Jackson2CodecSupport
JSON_VIEW_HINT, logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectWriter
customizeWriter
(ObjectWriter writer, MimeType mimeType, ResolvableType elementType, Map<String, Object> hints) Subclasses can use this method to customize theObjectWriter
used for writing values.Return the supported media type(s) forProblemDetail
.Methods inherited from class org.springframework.http.codec.json.AbstractJackson2Encoder
canEncode, encode, encodeValue, getAnnotation, getEncodableMimeTypes, getEncodableMimeTypes, getEncodeHints, getJsonEncoding, getStreamingMediaTypes, getStreamingMediaTypeSeparator, setStreamingMediaTypes
Methods inherited from class org.springframework.http.codec.json.Jackson2CodecSupport
getHints, getJavaType, getMimeTypes, getMimeTypes, getObjectMapper, getObjectMapperRegistrations, getObjectMappersForType, getParameter, logWarningIfNecessary, registerObjectMappersForType, selectObjectMapper, setObjectMapper, supportsMimeType
-
Constructor Details
-
Jackson2JsonEncoder
public Jackson2JsonEncoder() -
Jackson2JsonEncoder
-
-
Method Details
-
getMediaTypesForProblemDetail
Description copied from class:Jackson2CodecSupport
Return the supported media type(s) forProblemDetail
. By default, an empty list, unless overridden in subclasses.- Overrides:
getMediaTypesForProblemDetail
in classJackson2CodecSupport
-
customizeWriter
protected ObjectWriter customizeWriter(ObjectWriter writer, @Nullable MimeType mimeType, ResolvableType elementType, @Nullable Map<String, Object> hints) Description copied from class:AbstractJackson2Encoder
Subclasses can use this method to customize theObjectWriter
used for writing values.- Overrides:
customizeWriter
in classAbstractJackson2Encoder
- Parameters:
writer
- the writer instance to customizemimeType
- the selected MIME typeelementType
- the type of element values to writehints
- a map with serialization hints; the Reactor Context, when available, may be accessed under the keyContextView.class.getName()
- Returns:
- the customized
ObjectWriter
to use
-