public class KotlinSerializationJsonDecoder extends AbstractDecoder<Object>
This decoder can be used to bind @Serializable
Kotlin classes,
open polymorphic serialization
is not supported.
It supports application/json
and application/*+json
with
various character sets, UTF-8
being the default.
Decoding streams is not supported yet, see kotlinx.serialization/issues/1073 related issue.
logger
Constructor and Description |
---|
KotlinSerializationJsonDecoder() |
KotlinSerializationJsonDecoder(kotlinx.serialization.json.Json json) |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecode(ResolvableType elementType,
MimeType mimeType)
Whether the decoder supports the given target element type and the MIME
type of the source stream.
|
reactor.core.publisher.Flux<Object> |
decode(org.reactivestreams.Publisher<DataBuffer> inputStream,
ResolvableType elementType,
MimeType mimeType,
Map<String,Object> hints)
Decode a
DataBuffer input stream into a Flux of T . |
reactor.core.publisher.Mono<Object> |
decodeToMono(org.reactivestreams.Publisher<DataBuffer> inputStream,
ResolvableType elementType,
MimeType mimeType,
Map<String,Object> hints)
Decode a
DataBuffer input stream into a Mono of T . |
int |
getMaxInMemorySize()
Return the
configured byte count limit. |
void |
setMaxInMemorySize(int byteCount)
Configure a limit on the number of bytes that can be buffered whenever
the input stream needs to be aggregated.
|
getDecodableMimeTypes, getLogger, setLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, getDecodableMimeTypes
public KotlinSerializationJsonDecoder()
public KotlinSerializationJsonDecoder(kotlinx.serialization.json.Json json)
public void setMaxInMemorySize(int byteCount)
DataBuffer
,
ByteBuffer
, byte[]
,
Resource
, String
, etc.
It can also occur when splitting the input stream, e.g. delimited text,
in which case the limit applies to data buffered between delimiters.
By default this is set to 256K.
byteCount
- the max number of bytes to buffer, or -1 for unlimitedpublic int getMaxInMemorySize()
configured
byte count limit.public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
Decoder
canDecode
in interface Decoder<Object>
canDecode
in class AbstractDecoder<Object>
elementType
- the target element type for the output streammimeType
- the mime type associated with the stream to decode
(can be null
if not specified)true
if supported, false
otherwisepublic reactor.core.publisher.Flux<Object> decode(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Decoder
DataBuffer
input stream into a Flux of T
.inputStream
- the DataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream;
this type must have been previously passed to the Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returned true
.mimeType
- the MIME type associated with the input stream (optional)hints
- additional information about how to do decodepublic reactor.core.publisher.Mono<Object> decodeToMono(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable Map<String,Object> hints)
Decoder
DataBuffer
input stream into a Mono of T
.decodeToMono
in interface Decoder<Object>
decodeToMono
in class AbstractDecoder<Object>
inputStream
- the DataBuffer
input stream to decodeelementType
- the expected type of elements in the output stream;
this type must have been previously passed to the Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType)
method and it must have returned true
.mimeType
- the MIME type associated with the input stream (optional)hints
- additional information about how to do decode