https://kotlinlang.org logo
#jackson-kotlin
Title
# jackson-kotlin
j

Jukka Siivonen

10/21/2020, 4:47 PM
Hello, I'm having a problem with deserializing object using delegate interface, any ideas?
Copy code
class FooRequest(
    private val payload: PayloadImpl,
    override val someInterfaceField: Boolean
) : Payload by payload, SomeInterface
that one does not work but this will work without having additional "payload" object in JSON, I wonder why that is
Copy code
class FooRequest(
    private val payload: PayloadImpl
) : Payload by payload
alson @JsonUnwrapped does not work for deserialization because then I get problem described in
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot define Creator property "payload" as `@JsonUnwrapped`: combination not yet supported
What I would like to know is why the latter example behaves like its magically using @JsonUnrapped somehow
a

araqnid

10/22/2020, 10:55 AM
Istr that when the target class for deserialization has a single-parameter constructor, Jackson automagically supports deserializing to that constructor parameter and then calling the constructor - sort of an implicit builder pattern. I’ve certainly used this for constructing objects from strings during deserialization in the past
12 Views