I am trying to de-serialize a json string which has an enum as one of its value.
The enum structure is as follows
ENUM STATUS
{
ACTIVE(0), INACTIVE(1), EXPIRED(3)// Note here that 2 is not used due to some reasons
}
int status = 0;
public static Status getNameByValue(final int value) {
for (final Status s: Status.values()) {
if (s.status== value) {
return s;
}
}
return null;
}
}
When I am trying to read a json string which has this as one of its values as follows through rest
{"name":"Raj","status": 3}
I have got the following exception.
number value (3): index value outside legal index range [0..2]
at [Source: org.apache.catalina.connector.CoyoteInputStream@9e89a21; line: 1, column: 28] (through reference chain:
Kindly help me in this regard