Jackson 2.0与Jackson 1.x注释的兼容性? [英] Jackson 2.0 compatibility with Jackson 1.x annotations?

查看:134
本文介绍了Jackson 2.0与Jackson 1.x注释的兼容性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个较旧的框架类,用jackson 1.x注释。我的应用程序使用jackson 2.0来处理json序列化。是否可以配置jackson 2.0来理解旧注释?目前这些注释被忽略了。

I have an older framework class that is annotated with jackson 1.x. My application uses jackson 2.0 to handle json serialization. Is it possible to configure jackson 2.0 to understand the "old" annotations? currently these annotations are simply ignored.

推荐答案

没有开箱即用的配置,但它应该很容易实现Jackson 2.0 AnnotationIntrospector(可能扩展 JacksonAnnotationIntrospector )并使其除了2.x注释之外还使用Jackson 1.x注释。

There is no out-of-the-box configuration, but it should be quite easy to implement Jackson 2.0 AnnotationIntrospector (possibly extending JacksonAnnotationIntrospector) and make it use Jackson 1.x annotations in addition to or instead of 2.x annotations.

事实上,你基本上只需要1.x JacksonAnnotationIntrospector 并替换它的用法。

In fact, you could basically just take 1.x JacksonAnnotationIntrospector and replace its usage.

2.0不会也不会直接支持1.x注释的原因是它会引入额外的依赖关系,并可能导致版本冲突。但这并不妨碍外部图书馆这样做 - 事实上,如果有人想做出贡献,我相信杰克逊项目会接受github的Jackson 1.x annotations模块。

The reason 2.0 does not and will not support 1.x annotations directly is that it would pull in additional dependencies, and probably cause version conflicts. But that does not prevent external libraries from doing this -- in fact, if anyone wanted to contribute, I am sure Jackson project would accept "Jackson 1.x annotations" module for github.

这篇关于Jackson 2.0与Jackson 1.x注释的兼容性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆