How it works
Mark a data class @Serializable and a Kotlin compiler plugin generates its serializer, so encoding and decoding need no reflection. That makes it fast, friendly to R8 shrinking, and usable on every Kotlin Multiplatform target, unlike reflection-based libraries such as Gson. JSON is the main format; Protobuf, CBOR and others are available.
Options cover real-world APIs: ignoreUnknownKeys for servers that add fields, default values for missing ones, @SerialName for fields named differently on the wire, and polymorphic types. Ktor and supabase-kt use it, and Retrofit has a converter for it.
kotlinx.serialization pricing
Related terms
More in Mobile apps
Android building blocks