k_marussy
10/28/2018, 12:08 PMAs.PROPERTY
polymoprhic deserialization (e.g., {"type": "some.class.Name", "property": "value"}
instead of ["some.class.Name", {"property": "value"}]
) with kotlinx.serialization?
I actually have some even more polymorphic gnarly (de)serailization requirements, which I could handle by some pretty ugly custom Jackson (de)serializers, but I would be interested a JVM-idependent solution. A key idea seems to be some kind of lookahead, during which Jackson can put tokens into a TokenBuffer
while searching for the "type"
attribute, and prefix the remaining token stream with the buffer contents upon calling the concrete deserializer. As the JSON schema I have to handle clearly wasn't designed with ease of parsing in mind, I have to rely a lot on lookahead.
I am unsure how to achieve something similar with KInput
and KSerialClassDesc
.sandwwraith
10/29/2018, 9:26 AMk_marussy
10/29/2018, 10:20 AMtarek
10/29/2018, 7:19 PMk_marussy
10/29/2018, 7:33 PMJSON
uses JSON.JsonInput
, inside JsonTreeMapper#readTree
, you get passed JsonTreeMapper.JsonTreeInput
, which is private, and thus there is not way to extract the current JsonElement
😞tarek
10/29/2018, 10:04 PMk_marussy
10/29/2018, 10:36 PMJsonTreeMapper
and try out recursive polymorphic serialization that way.sandwwraith
10/30/2018, 9:44 AMk_marussy
10/30/2018, 2:54 PM