I have a request coming like this
{
\"varA\" : \"A\",
\"varB\" : \"TCFNhbiBKb3NlMRgwFgYDVQQK\"
}
where key varB
is a
I've done some experiments and here is a simple Jackson Deserializer which should work for you.
Deserializer implements the ContextualDeserializer interface to get access to actual bean property (for example varB
). It's necessary for detecting correct result type, because deserializer itself can be attached to a field of any type.
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.deser.ContextualDeserializer;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
import java.io.IOException;
import java.util.Base64;
public class Base64Deserializer extends JsonDeserializer
Here is an example of mapped class.
public class MyRequest {
private String varA;
@JsonDeserialize(using = Base64Deserializer.class)
private B varB;
public String getVarA() {
return varA;
}
public void setVarA(String varA) {
this.varA = varA;
}
public B getVarB() {
return varB;
}
public void setVarB(B varB) {
this.varB = varB;
}
}