public abstract class DeserializationProblemHandler extends Object
DeserializationConfig
object owner by
ObjectMapper
) to get called when a potentially
recoverable problem is encountered during deserialization
process. Handlers can try to resolve the problem, throw
an exception or just skip the content.
Default implementations for all methods implemented minimal "do nothing" functionality, which is roughly equivalent to not having a registered listener at all. This allows for only implemented handler methods one is interested in, without handling other cases.
NOTE: it is typically NOT acceptable to simply do nothing,
because this will result in unprocessed tokens being left in
token stream (read via JsonParser
, in case a structured
(JSON Object or JSON Array) value is being pointed to by parser.
Constructor and Description |
---|
DeserializationProblemHandler() |
Modifier and Type | Method and Description |
---|---|
boolean |
handleUnknownProperty(DeserializationContext ctxt,
JsonParser jp,
JsonDeserializer<?> deserializer,
Object beanOrClass,
String propertyName)
Method called when a JSON Map ("Object") entry with an unrecognized
name is encountered.
|
public boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser jp, JsonDeserializer<?> deserializer, Object beanOrClass, String propertyName) throws IOException, JsonProcessingException
jp.skipChildren();
Note: version 1.2 added new deserialization feature
(DeserializationConfig.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
).
It will only have effect after handler is called, and only
if handler did not handle the problem.
beanOrClass
- Either bean instance being deserialized (if one
has been instantiated so far); or Class that indicates type that
will be instantiated (if no instantiation done yet: for example
when bean uses non-default constructors)jp
- Parser to use for handling problematic contentIOException
JsonProcessingException
Copyright © 2008–2018 FasterXML. All rights reserved.