janvladimirmostert
12/13/2022, 11:09 AM{
"field1":"a field that's always there"
"field2":"a field that's sometimes there, other times not and the content varies from Boolean to String to Dates to numbers"
}
Is it possible to have ignoreUnknownKeys=false
and then have a list of fields that I can ignore?
I want it to throw an error if they send for example JSON that now has a field3
, but I don't want to care about field2
and I definitely don't want it in my model.
I'm already using a custom JsonContentPolymorphicSerializer so that I can switch between different types for one of the other fieldsAdam S
12/13/2022, 11:40 AMfield2
to be JsonElement
,
• and have field2
defined in code but document it as @Deprecated
- perhaps even with the visibility set to ‘hidden’Adam S
12/13/2022, 11:51 AM@Serializable(with = IgnoredFieldSerializer::class) object IgnoredField
• set IgnoredFieldSerializer
descriptor to be a primitive, and configure it so it will always decode to object IgnoredField
, and encode nothing, or null
• set val field2: IgnoredField?