@ -673,48 +673,45 @@ readers and writers for form data, multipart requests, and server-sent events.
@@ -673,48 +673,45 @@ readers and writers for form data, multipart requests, and server-sent events.
[[webflux-codecs-jackson]]
==== Jackson JSON
The decoder relies on Jackson's non-blocking, byte-array parser to parse a stream of byte
chunks into a `TokenBuffer` stream, which can then be turned into objects with Jackson's
`ObjectMapper`. The JSON and https://github.com/FasterXML/smile-format-specification[Smile]
(binary JSON) data formats are currently supported.
JSON and binary JSON (https://github.com/FasterXML/smile-format-specification[Smile]) data
formats are both supported.
The encoder processes a `Publisher<?>`, as follows:
The `Jackson2Decoder` uses Jackson's asynchronous, non-blocking parser to create a stream
of ``TokenBuffer``'s and then each `TokenBuffer` is passed to Jackson's `ObjectMapper` to
create a higher level object. When decoding to a multi-value publisher (e.g. `Flux`), the
input stream can be a JSON array, or
https://en.wikipedia.org/wiki/JSON_streaming[line-delimited JSON] if the content-type is
"application/stream+json".
* If the `Publisher` is a `Mono` (that is, a single value), the value is encoded when available.
* If media type is `application/stream+json` for JSON or `application/stream+x-jackson-smile`
for Smile, each value produced by the `Publisher` is encoded individually (and followed
by a new line in JSON).
* Otherwise, all items from the `Publisher` are gathered in with `Flux#collectToList()`,
and the resulting collection is encoded as an array.
The `Jackson2Encoder` works as follows:
As a special case to the preceding rules, the `ServerSentEventHttpMessageWriter` feeds items
emitted from its input `Publisher` individually into the `Jackson2JsonEncoder` as a
`Mono<?>`.
* For a single value publisher (e.g. `Mono`), simply serialize it.
* For a multi-value publisher with "application/json", collect the values with
`Flux#collectToList()` and then serialize the resulting collection.
* For a multi-value publisher with a streaming media type such as
`application/stream+json` or `application/stream+x-jackson-smile`, encode, write, and