Package kotlinx.serialization.builtins

Serializers for standard Kotlin types, like Int, String, List, etc.

Types

Link copied to clipboard
object LongAsStringSerializer : KSerializer<Long>

Serializer that encodes and decodes Long as its string representation.

Functions

Link copied to clipboard
inline fun <T : Any, E : T?> ArraySerializer(elementSerializer: KSerializer<E>): KSerializer<Array<E>>
fun <T : Any, E : T?> ArraySerializer(kClass: KClass<T>, elementSerializer: KSerializer<E>): KSerializer<Array<E>>

Returns serializer for reference Array of type E with descriptor of StructureKind.LIST kind. Each element of the array is serialized with the given elementSerializer.

Link copied to clipboard
fun BooleanArraySerializer(): KSerializer<BooleanArray>

Returns serializer for BooleanArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Boolean.Companion.serializer.

Link copied to clipboard
fun ByteArraySerializer(): KSerializer<ByteArray>

Returns serializer for ByteArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Byte.Companion.serializer.

Link copied to clipboard
fun CharArraySerializer(): KSerializer<CharArray>

Returns serializer for CharArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Char.Companion.serializer.

Link copied to clipboard
fun DoubleArraySerializer(): KSerializer<DoubleArray>

Returns serializer for DoubleArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Double.Companion.serializer.

Link copied to clipboard
fun FloatArraySerializer(): KSerializer<FloatArray>

Returns serializer for FloatArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Float.Companion.serializer.

Link copied to clipboard
fun IntArraySerializer(): KSerializer<IntArray>

Returns serializer for IntArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Int.Companion.serializer.

Link copied to clipboard
fun <T> ListSerializer(elementSerializer: KSerializer<T>): KSerializer<List<T>>

Creates a serializer for List<T> for the given serializer of type T.

Link copied to clipboard
fun LongArraySerializer(): KSerializer<LongArray>

Returns serializer for LongArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Long.Companion.serializer.

Link copied to clipboard
fun <K, V> MapEntrySerializer(keySerializer: KSerializer<K>, valueSerializer: KSerializer<V>): KSerializer<Map.Entry<K, V>>

Returns built-in serializer for Map.Entry. Resulting serializer represents entry as a structure with a single key-value pair. E.g. Pair(1, 2) and Map.Entry(1, 2) will be serialized to JSON as {"first": 1, "second": 2} and {"1": 2} respectively.

Link copied to clipboard
fun <K, V> MapSerializer(keySerializer: KSerializer<K>, valueSerializer: KSerializer<V>): KSerializer<Map<K, V>>

Creates a serializer for Map<K, V> for the given serializers for its ket type K and value type V.

Link copied to clipboard
fun <K, V> PairSerializer(keySerializer: KSerializer<K>, valueSerializer: KSerializer<V>): KSerializer<Pair<K, V>>

Returns built-in serializer for Kotlin Pair. Resulting serializer represents pair as a structure of two key-value pairs.

Link copied to clipboard
fun Boolean.Companion.serializer(): KSerializer<Boolean>

Returns serializer for Boolean with descriptor of PrimitiveKind.BOOLEAN kind.

fun Byte.Companion.serializer(): KSerializer<Byte>

Returns serializer for Byte with descriptor of PrimitiveKind.BYTE kind.

fun Char.Companion.serializer(): KSerializer<Char>

Returns serializer for Char with descriptor of PrimitiveKind.CHAR kind.

fun Double.Companion.serializer(): KSerializer<Double>

Returns serializer for Double with descriptor of PrimitiveKind.DOUBLE kind.

fun Float.Companion.serializer(): KSerializer<Float>

Returns serializer for Float with descriptor of PrimitiveKind.FLOAT kind.

fun Int.Companion.serializer(): KSerializer<Int>

Returns serializer for Int with descriptor of PrimitiveKind.INT kind.

fun Long.Companion.serializer(): KSerializer<Long>

Returns serializer for Long with descriptor of PrimitiveKind.LONG kind.

fun Short.Companion.serializer(): KSerializer<Short>

Returns serializer for Short with descriptor of PrimitiveKind.SHORT kind.

fun String.Companion.serializer(): KSerializer<String>

Returns serializer for String with descriptor of PrimitiveKind.STRING kind.

fun UByte.Companion.serializer(): KSerializer<UByte>

Returns serializer for UByte.

fun UInt.Companion.serializer(): KSerializer<UInt>

Returns serializer for UInt.

fun ULong.Companion.serializer(): KSerializer<ULong>

Returns serializer for ULong.

fun UShort.Companion.serializer(): KSerializer<UShort>

Returns serializer for UShort.

fun Unit.serializer(): KSerializer<Unit>

Returns serializer for Unit with descriptor of StructureKind.OBJECT kind.

fun Duration.Companion.serializer(): KSerializer<Duration>

Returns serializer for Duration. It is serialized as a string that represents a duration in the ISO-8601 format.

Link copied to clipboard
fun <T> SetSerializer(elementSerializer: KSerializer<T>): KSerializer<Set<T>>

Creates a serializer for Set<T> for the given serializer of type T.

Link copied to clipboard
fun ShortArraySerializer(): KSerializer<ShortArray>

Returns serializer for ShortArray with descriptor of StructureKind.LIST kind. Each element of the array is serialized one by one with Short.Companion.serializer.

Link copied to clipboard
fun <A, B, C> TripleSerializer(    aSerializer: KSerializer<A>,     bSerializer: KSerializer<B>,     cSerializer: KSerializer<C>): KSerializer<Triple<A, B, C>>

Returns built-in serializer for Kotlin Triple. Resulting serializer represents triple as a structure of three key-value pairs.

Properties

Link copied to clipboard
val <T : Any> KSerializer<T>.nullable: KSerializer<T?>

Returns a nullable serializer for the given serializer of non-null type.