is it possible to deserialize enums, which have a one based index?
enum Status {
Active,
Inactive
}
{status:1} means Status.Active, but Jac
Enums have numeric ordinals, starting in zero, and get assigned to each value in an enumeration in the order in which they were declared. For example, in your code Active
has ordinal 0
and Inactive
has ordinal 1
. You can go back and forth between the value of an enum and its ordinal, like this:
// ordinal=0, since Active was declared first in the enum
int ordinal = Status.Active.ordinal();
// enumVal=Active, since 0 is the ordinal corresponding to Active
Status enumVal = Status.values()[0];
Clearly the ordinal 1
corresponds to Inactive
(it's not a Jackson problem), as explained above, ordinals in an enumeration are zero-based. Maybe you should fix your code to reflect that, and make sure that {status:0}
means Status.Active
.