decodeToSequence

fun <T> Json.decodeToSequence(    stream: InputStream,     deserializer: DeserializationStrategy<T>,     format: DecodeSequenceMode = DecodeSequenceMode.AUTO_DETECT): Sequence<T>

Transforms the given stream into lazily deserialized sequence of elements of type T using UTF-8 encoding and deserializer. Unlike decodeFromStream, stream is allowed to have more than one element, separated as format declares.

Elements must all be of type T. Elements are parsed lazily when resulting Sequence is evaluated. Resulting sequence is tied to the stream and can be evaluated only once.

Resource caution: this method neither closes the stream when the parsing is finished nor provides a method to close it manually. It is a caller responsibility to hold a reference to a stream and close it. Moreover, because stream is parsed lazily, closing it before returned sequence is evaluated completely will result in IOException from decoder.

Throws

if the given JSON input cannot be deserialized to the value of type T.

if the decoded input cannot be represented as a valid instance of type T

If an I/O error occurs and stream cannot be read from.


inline fun <T> Json.decodeToSequence(stream: InputStream, format: DecodeSequenceMode = DecodeSequenceMode.AUTO_DETECT): Sequence<T>

Transforms the given stream into lazily deserialized sequence of elements of type T using UTF-8 encoding and deserializer retrieved from the reified type parameter. Unlike decodeFromStream, stream is allowed to have more than one element, separated as format declares.

Elements must all be of type T. Elements are parsed lazily when resulting Sequence is evaluated. Resulting sequence is tied to the stream and constrained to be evaluated only once.

Resource caution: this method does not close stream when the parsing is finished neither provides method to close it manually. It is a caller responsibility to hold a reference to a stream and close it. Moreover, because stream is parsed lazily, closing it before returned sequence is evaluated fully would result in IOException from decoder.

Throws

if the given JSON input cannot be deserialized to the value of type T.

if the decoded input cannot be represented as a valid instance of type T

If an I/O error occurs and stream cannot be read from.