I believe that we need our own deserializer to do something specific with one field of our class. As soon as I do this, I am now responsible for deserializing all the other fields. Is there a way for Jackson to deserialize all fields except the ones I'm interested in here?
public class ThingDeseralizer extends StdDeserializer<Thing> {
ββββ@Override
ββββpublic Thing deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ββββββ ObjectCodec oc = p.getCodec();
ββββββββJsonNode node = oc.readTree(p);
ββββββββString special = node.get("special").asText();
Thing thing = new Thing()
ββββββββthing.doSomethignWithSpecial(special)
ββββββββreturn thing;
}
}
Thanx
source
share