I am struggling to achieve the following functionality: deserialize dynamic properties (incoming json) into array field/map.
Input:
{
dynamic_field1: "value1",
dynamic_field2: "value2",
...
name: "John",
age: 20
...
}
into Kotlin data class (although being a kotlin data class is not that relevant):
@JsonDeserialize(using = PersonDeserializer::class)
data class Person(
val personName: String,
@JsonProperty(using = SpecificIntDeserializer::class)
val age: Int,
val dymamicProperties: Map<String, String>
)
So essentially use (delegate) provided or default bean deserializer (whenever possible) BUT also get all fields that start with dynamic_ and process them separately.
What I tried so far:
- find the
ValueInstantiator, iterate through the main constructor (instantiator.withArgsCreator) and for each parameter find the right deserializer; however, I am unable to connect this with right JsonToken - tried
ContextualDeserializerandResolvableDeserializerbut got lost.
Any suggestions?