orchestr7 / ktoml

Kotlin Multiplatform parser and compile-time serializer/deserializer for TOML format (Native, JS, JVM) based on KxS
https://akuleshov7.github.io/ktoml
MIT License
449 stars 24 forks source link

Allow Missing Properties as a configuration option #239

Closed Wavesonics closed 1 year ago

Wavesonics commented 1 year ago

It would be nice if we could configure the deserializer to be more lenient, such that if a field is missing from the serialized form, that is nullable in the data class, it just assigns null.

@Serializable
data class Info(
    val created: String,
    val lastAccessed: String?,
)

And I try to decode:

created="now"

It will just assign null to lastAccessed

Wavesonics commented 1 year ago

nevermind, I see that giving it a default value of null solves the issue