decodeBufferedSourceToSequence

Transforms the given source into lazily deserialized sequence of elements of type T using UTF-8 encoding and deserializer. Unlike decodeFromBufferedSource, source 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 source when the parsing is finished nor provides a method to close it manually. It is a caller responsibility to hold a reference to a source and close it. Moreover, because source is parsed lazily, closing it before returned sequence is evaluated completely will result in Exception from decoder.

Throws

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

If an I/O error occurs and source can't be read from.


inline fun <T> Json.decodeBufferedSourceToSequence(source: BufferedSource, format: DecodeSequenceMode = DecodeSequenceMode.AUTO_DETECT): Sequence<T>(source)

Transforms the given source into lazily deserialized sequence of elements of type T using UTF-8 encoding and deserializer retrieved from the reified type parameter. Unlike decodeFromBufferedSource, source 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 source when the parsing is finished neither provides method to close it manually. It is a caller responsibility to hold a reference to a source and close it. Moreover, because source is parsed lazily, closing it before returned sequence is evaluated fully would result in Exception from decoder.

Throws

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

If an I/O error occurs and source can't be read from.