decodeFromStream

fun <T> Json.decodeFromStream(deserializer: DeserializationStrategy<T>, stream: InputStream): T

Deserializes JSON from stream using UTF-8 encoding to a value of type T using deserializer.

Note that this functions expects that exactly one object would be present in the stream and throws an exception if there are any dangling bytes after an object.

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.decodeFromStream(stream: InputStream): T

Deserializes the contents of given stream to the value of type T using UTF-8 encoding and deserializer retrieved from the reified type parameter.

Note that this functions expects that exactly one object would be present in the stream and throws an exception if there are any dangling bytes after an object.

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.