import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
import java.io.IOException;
public class ErrorHandlingDeserializerModifier extends BeanDeserializerModifier {
@Override
public JsonDeserializer<?> modifyDeserializer(final DeserializationConfig config, final BeanDescription beanDesc, final JsonDeserializer<?> deserializer) {
JsonDeserializer<?> jdesc = super.modifyDeserializer(config, beanDesc, deserializer);
return new JsonDeserializer<Object>() {
@Override
public Object deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
try {
return jdesc.deserialize(p,ctxt);
} catch (JsonMappingException jme) {
//add errors to map
...
return null;
}
}
};
}
}
com.fasterxml.jackson.databind.exc.MismatchedInputException: No _valueDeserializer assigned
at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: Jurisdiction["id"])
at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:62)
at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1294)
at com.fasterxml.jackson.databind.deser.impl.FailingDeserializer.deserialize(FailingDeserializer.java:29)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:124)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:275)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:139)
at com.company.ErrorHandlingDeserializerModifier$1.deserialize(ErrorHandlingDeserializerModifier.java:25)
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3666)
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3589)
public class LameBeanOfUncreativeness {
private UUID id;
private String name;
//geoJson see https://github.com/bedatadriven/jackson-datatype-jts
private com.vividsolutions.jts.geom.MultiPolygon
private String anotherWorthlessString;
...getters/setters
}
{
"id" : "b644ed02-26dd-11e7-93ae-92361f002671", "name" : "name",
"geometry" : {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-111.78458342744,
40.6768905586
],
[
-111.784777398489,
40.676681591667
],
[
-111.784794225842,
40.6766635501376
],
[
-111.784813388878,
40.6766428802297
],
[
-111.785118238289,
"Lenin wanted to destroy this deserialization operation, and that’s my goal too"
],
[
-111.785092595041,
40.6768713732734
],
[
-111.785068477072,
40.6768954906377
],
[
-111.785045942486,
40.6769204799231
],
[
-111.785025045571,
40.6769462809292
],
[
-111.78500583667,
40.6769728314999
],
[
-111.784990180876,
40.6769970682503
],
[
-111.784959647803,
40.6770470934933
],
[
-111.78458342744,
40.6768905586
]
]
]
]
},
"anotherWorthlessString" : "Another Worthless Value"
}