public class Jackson2JsonEncoder extends AbstractJackson2Codec implements Encoder<java.lang.Object>
Object
stream to a byte stream of JSON objects,
using Jackson 2.6+.Jackson2JsonDecoder
Modifier and Type | Field and Description |
---|---|
private PrettyPrinter |
ssePrettyPrinter |
JSON_MIME_TYPES, JSON_VIEW_HINT, mapper
Constructor and Description |
---|
Jackson2JsonEncoder() |
Jackson2JsonEncoder(ObjectMapper mapper) |
Modifier and Type | Method and Description |
---|---|
boolean |
canEncode(ResolvableType elementType,
MimeType mimeType)
Whether the encoder supports the given source element type and the MIME
type for the output stream.
|
<any> |
encode(<any> inputStream,
DataBufferFactory bufferFactory,
ResolvableType elementType,
MimeType mimeType,
java.util.Map<java.lang.String,java.lang.Object> hints)
Encode a stream of Objects of type
T into a DataBuffer
output stream. |
private DataBuffer |
encodeValue(java.lang.Object value,
DataBufferFactory bufferFactory,
ResolvableType type,
java.util.Map<java.lang.String,java.lang.Object> hints) |
java.util.List<MimeType> |
getEncodableMimeTypes()
Return the list of mime types this encoder supports.
|
getJavaType
public Jackson2JsonEncoder()
public Jackson2JsonEncoder(ObjectMapper mapper)
public boolean canEncode(ResolvableType elementType, MimeType mimeType)
Encoder
public java.util.List<MimeType> getEncodableMimeTypes()
Encoder
getEncodableMimeTypes
in interface Encoder<java.lang.Object>
public <any> encode(<any> inputStream, DataBufferFactory bufferFactory, ResolvableType elementType, MimeType mimeType, java.util.Map<java.lang.String,java.lang.Object> hints)
Encoder
T
into a DataBuffer
output stream.encode
in interface Encoder<java.lang.Object>
inputStream
- the input stream of Objects to encode. If the input should be
encoded as a single value rather than as a stream of elements, an instance of
Mono
should be used.bufferFactory
- for creating output stream DataBuffer
'selementType
- the expected type of elements in the input stream;
this type must have been previously passed to the Encoder.canEncode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returned true
.mimeType
- the MIME type for the output streamhints
- additional information about how to do encodeprivate DataBuffer encodeValue(java.lang.Object value, DataBufferFactory bufferFactory, ResolvableType type, java.util.Map<java.lang.String,java.lang.Object> hints)