Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
You’re using encodeToString which is a reified function, in simple terms it gets the type of the value that you pass to it, at compile time, and creates a proper serializer for you. A more verbose but more obvious version of your code would be Json.encodeToString( serializer>(), mapOf(...)) Just makes it more obvious that your mapOf call results in a map with value type Any. And Kotlin serialization will then use Any’s serializer for all of that Map’s values. Refer here to solve your issue https://github.com/Kotlin/kotlinx.serialization/issues/296
Related posts
- How would I serialize a JSON primitive to a class?
- kotlinx-serialization won't serialize a List?
- [Android/Multiplatform] Kotlin Flows + Ktor = Flawless HTTP requests (- ArrowKt)
- Question about app weight... I want to use Apache commons math3, should I fork it and "crop" it to reduce compile times and app weight?
- kotlinx.serialization 1.4.0 is out!