Closed
Description
What is your use-case and why do you need this feature?
Ability to parse nullable properties when the keys are not present in the JSON.
@kotlinx.serialization.Serializable
data class Foo(val foo: String?)
Trying to parse this JSON string {}
fails.
The current workaround would be to add a default value val foo: String? = null
. However, we don't always have access to the entities in order to apply the fix. One example is when trying to create external serializers for the SqlDelight autogenerated entities.
Describe the solution you'd like
Add a configuration acceptNonPresentKeys
which when set to true, the parser would automatically produce
Foo(foo = null)
when {}
this is provided.