https://kotlinlang.org logo
#getting-started
Title
# getting-started
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
Copy code
data class Person (val gender: GenderEnum)
GenderEnum
Copy code
enum class GenderEnum(val type: Sring) {
MALE("MALE")
FEMALE("FEMALE")
OTHER("OTHER")
}
and my api response is
Copy code
"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:
Copy code
data class Data(val data: Person)
28 Views