Question: Expected behaviour of JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES

95 views
Skip to first unread message

Chin Ming Jun

unread,
Jan 5, 2023, 7:55:08 PM1/5/23
to jackson-user
Hello folks,

We have a use case where we are trying to convert the JSON field value with lower capitalization to an enum with its name capitalized. 

Consider the following example:
Input string:
{
    "id": "1",
    "status": "joined"
}

and the POJO class:
@Jacksonized
public class Member {
    String id;
    MemberStatus status;
}

public enum MemberStatus {
    JOINED;
    DEACTIVATED;
}

With this use case in mind, we opt-ed to annotate the status field of Member class with @JsonFormat(with=JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_VALUES)

However, we find out instead of ACCEPT_CASE_INSENSITIVE_VALUES, the ACCEPT_CASE_INSENSITIVE_PROPERTIES format is the one that sets the caseInsensitive of EnumDeserializer to true. 

Based on the documentation, the ACCEPT_CASE_INSENSITIVE_PROPERTIES should "allows case-insensitive matching of property names (but NOT values, see ACCEPT_CASE_INSENSITIVE_VALUES for that)." But the behavior seems to be the totally opposite of what's being described in the documentation.

Am I missing something here?

Thank you
Reply all
Reply to author
Forward
0 new messages