I have a lib which i cannot change.
This lib has api method which returns json like this {OrderStatus=PartiallyFilledCanceled}
and also this lib has a enum
@AllArgsConstructor
public enum OrderStatus {
PARTIALLY_FILLED_CANCELED("PartiallyFilledCanceled");
private final String description;
}
and dto with OrderStatus field.
So I got an error
java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `com.api.client.domain.OrderStatus` from String "PartiallyFilledCanceled": not one of the values accepted for Enum class:[PARTIALLY_FILLED_CANCELED]
My ObjectMapper configs:
objectMapper.registerModule(new JavaTimeModule());
objectMapper.enable(JsonParser.Feature.IGNORE_UNDEFINED);
objectMapper.coercionConfigFor(LogicalType.Enum).setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsNull);
How can I use some custom deserializer without changing dto?