【发布时间】:2013-12-10 19:37:18
【问题描述】:
我有一堆接口注释如下:
@MyAnnotation(DefaultImplementation.class)
interface SomeInterface {
...
}
以及相应的实现
class DefaultImplementation implements SomeInterface {
...
}
当我的 ObjectMapper 遇到 SomeInterface 类型的字段时,我希望它像 DefaultImplementation 一样反序列化它。也就是说,我想在反序列化过程中编码如下逻辑:
if (staticTypeToDeserialize.isAnnotationPresent(MyAnnotation.class))
deserializeAs(type.getAnnotation(MyAnnotation.class).value());
else
fallBackOnRegularDeserialization();
【问题讨论】:
标签: json jackson deserialization