@JsonEnumDefaultValue se usa para deserializar un valor de enumeración desconocido usando un valor predeterminado.
Ejemplo @JsonEnumDefaultValue
import java.io.IOException;
import java.text.ParseException;
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JacksonTester {
public static void main(String args[]) throws ParseException{
ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
String jsonString = "\"abc\"";
try {
LETTERS value = mapper.readValue(jsonString, LETTERS.class);
System.out.println(value);
}
catch (IOException e) {
e.printStackTrace();
}
}
}
enum LETTERS {
A, B, @JsonEnumDefaultValue UNKNOWN
}
Salida
UNKNOWN