Given a JSON that looks like {statusCode:401} , how can I deserialize it in the following listing using Jackson 2. The main problem is that when deserializing I only have a status code, not a description.
public enum RestApiHttpStatus { OK(200, "Ok"), INTERNAL_SERVER_ERROR(500, "Internal Server Error"), BAD_REQUEST(400, "Bad Request"), UNAUTHORIZED(401, "Unauthorized"), FORBIDDEN(403, "Forbidden"), NOT_FOUND(404, "Not Found"); private final int statusCode; private final String description; private RestApiHttpStatus(int statusCode, String description) { this.statusCode = statusCode; this.description = description; } public int getStatusCode() { return statusCode; } public String getDescription() { return description; } }
How to configure Jackson2 to solve this situation?
source share