Jackson not recognizing 'is' Fields unless annoated with @JsonProperty

I have discovered the following problem whenever I have an "is" field in my JSON String Jackson doesn’t detect it without the additional @JsonProperty Tag. Before reporting this as a Bug, I wanted to make sure this is not caused by me. The UnmappedPropertyHandler interface is just a method with an @JsonAnySetter to report any unknown fields, which it does for the "is" Fields whenever they are not annotated with @JsonProperty and their name between the ( ).

public class Event implements UnmappedPropertyHandler {

    private boolean expired, isCommunity, isPersonal, active;

    public boolean isExpired() {
        return expired;
    }

    public boolean isCommunity() {
        return isCommunity;
    }

    public boolean isPersonal() {
        return isPersonal;
    }

    public boolean isActive() {
        return active;
    }

Snippet of the JSON String I’m parsing.

{
  "id": "5c7cb0d00000000000000000",
  "activation": "2022-06-01T16:00:00.000Z",
  "startString": "-11d 17h 33m 47s",
  ....
  "isPersonal": true,
  "isCommunity": true,
  ....
}

>Solution :

Jackson apparently scans the class that you pass in for getters and setters
and then use those methods for serialization and deserialization.

"Get", "Set", "is" are eliminated and what remains in those methods will be used as Json field.

Hence your "isCommunity" is changed into "community" and so on.

Leave a Reply