Kotlin Serialization Properties.decodeFromMap returns null for nullable types.
Nullable fields are populated if the value is present in the map.
For consistency, same behaviour should be expected at top-level nullable type.
Or else this behaviour should be documented to avoid confusion.
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.Serializable
import kotlinx.serialization.properties.Properties
import kotlinx.serialization.properties.decodeFromMap
@Serializable
data class User(val id: String)
@ExperimentalSerializationApi
fun main() {
val map = mapOf("id" to "some user id")
val user: User = Properties.decodeFromMap(map)
println("user: $user") // user: User(id=some user id)
val nullableUser: User? = Properties.decodeFromMap(map)
println("nullableUser: $nullableUser") // nullableUser: null
}