Jackson 2.0 compatibility with Jackson 1.x annotations?

╄→гoц情女王★ 提交于 2019-12-23 11:48:53

问题


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.


回答1:


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.

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

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.



来源:https://stackoverflow.com/questions/12461760/jackson-2-0-compatibility-with-jackson-1-x-annotations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!