Package-level declarations

Extensions for kotlinx.serialization.json.Json for integration with the kotlinx-io library.

Functions

Link copied to clipboard
inline fun <T> Json.decodeFromSource(source: Source): T

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

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

Link copied to clipboard
inline fun <T> Json.decodeSourceToSequence(source: Source, format: DecodeSequenceMode = DecodeSequenceMode.AUTO_DETECT): Sequence<T>

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 decodeSourceToSequence, source is allowed to have more than one element, separated as format declares.

fun <T> Json.decodeSourceToSequence(source: Source, deserializer: DeserializationStrategy<T>, format: DecodeSequenceMode = DecodeSequenceMode.AUTO_DETECT): Sequence<T>

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

Link copied to clipboard
inline fun <T> Json.encodeToSink(value: T, sink: Sink)

Serializes given value to a sink using UTF-8 encoding and serializer retrieved from the reified type parameter.

fun <T> Json.encodeToSink(serializer: SerializationStrategy<T>, value: T, sink: Sink)

Serializes the value with serializer into a sink using JSON format and UTF-8 encoding.