https://kotlinlang.org logo
Title
a

Ahmed

02/23/2022, 3:34 PM
Hey guys, I have a problem with jackson deserialization I have a model that has a field of an Enum type
data class Person (val gender: GenderEnum)
GenderEnum
enum class GenderEnum(val type: Sring) {
MALE("MALE")
FEMALE("FEMALE")
OTHER("OTHER")
}
and my api response is
"data": { gender: "male" }
Now, I am getting an error saying,
Cannot construct instance of the Person class, problem: Parameter specified as non-null is null: gender
anyone has the problem with jackson before ?
m

marstran

02/23/2022, 3:42 PM
There's a data-field in your JSON. You probably need another wrapper class as well:
data class Data(val data: Person)