com.fasterxml.jackson.databind.deser
Class DeserializationProblemHandler
java.lang.Object
com.fasterxml.jackson.databind.deser.DeserializationProblemHandler
public abstract class DeserializationProblemHandler
- extends Object
This is the class that can be registered (via
DeserializationConfig
object owner by
ObjectMapper
) to get calledn when a potentially
recoverable problem is encountered during deserialization
process. Handlers can try to resolve the problem, throw
an exception or do nothing.
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.
- Author:
- tatu
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DeserializationProblemHandler
public DeserializationProblemHandler()
handleUnknownProperty
public boolean handleUnknownProperty(DeserializationContext ctxt,
com.fasterxml.jackson.core.JsonParser jp,
JsonDeserializer<?> deserializer,
Object beanOrClass,
String propertyName)
throws IOException,
com.fasterxml.jackson.core.JsonProcessingException
- Method called when a Json Map ("Object") entry with an unrecognized
name is encountered.
Content (supposedly) matching the property are accessible via
parser that can be obtained from passed deserialization context.
Handler can also choose to skip the content; if so, it MUST return
true to indicate it did handle property succesfully.
Skipping is usually done like so:
ctxt.getParser().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.
- Parameters:
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 content
- Returns:
- True if the problem was succesfully resolved (and content available
used or skipped); false if listen
- Throws:
IOException
com.fasterxml.jackson.core.JsonProcessingException
Copyright © 2012 fasterxml.com. All Rights Reserved.