jsonapi-converter icon indicating copy to clipboard operation
jsonapi-converter copied to clipboard

@JsonProperty unexpectedly required

Open Human opened this issue 5 years ago • 1 comments

I have a JSON object with a boolean isFavorite field, like so (simplified, obviously):

{ "attributes": { "isFavorite": false }}

If my kotlin class for parsing this object has an un-annotated isFavorite field, like so:

var isFavorite: Boolean? = null

The resulting object's isFavorite field remains null. However, if I redundantly annotate it with @JsonProperty like so:

@JsonProperty("isFavorite") var isFavorite: Boolean? = null

it works as expected.

Human avatar Dec 17 '19 20:12 Human

I have exactly the same issue. I have an object with a var isFavorite: Boolean that is not parsed at all. @Human trick worked but why is this happening?

pedrolaranjeiro avatar May 05 '20 09:05 pedrolaranjeiro

This is related to how Jackson works and not to the lib.

jasminb avatar Jul 31 '24 20:07 jasminb