using kotlinx and given a JSON input like {"a": 123, "b": "foo", "c": false}, is there a smart way to have this deserialized into a POJO where the property values contain the original value and the respective serial name of the property?
@Serializable
class Slot<T>(val name: String, val value: T)
@Serializable
class Slots(
@SerialName("a")
propertyA: Slot<Integer?>? = null,
@SerialName("b")
propertyB: Slot<String?>? = null,
@SerialName("c")
propertyC: Slot<Boolean?>? = null
)
So the resulting object in Kotlin would effectively look like this: { propertyA={name="a", value=123}, propertyB={name="b", value="foo"}, propertyC={name="c", value=false} }.
I can't seem to find anything appropriate in the kotlinx docs but might be overlooking something.
Any help is much appreciated!