I have a requirement to strip off all the special characters and control characters from the fields of type String in any of the Objects. Deserializer was registered but never executes during the runtime for Strings.
I tried adding the same as an annotation @JsonDeserialize(using = StringProcessorComponent.class), but the same issue.
It works for any other type like Date/Long. Please let me know if I am missing any.
Here is my Deserializer.
@JsonComponent
public class StringProcessorComponent extends JsonDeserializer<String> {
@Override
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonToken currentToken = p.getCurrentToken();
if (currentToken.equals(JsonToken.VALUE_STRING)) {
String text = MyStringProcessor.clean(p.getValueAsString());
return text;
}
return null;
}
}