Jackson 2.0 compatibility with Jackson 1.x comments?

I have an older frame class that annotates 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.

+4
source share
1 answer

There is no ready-made configuration, but it is quite simple to implement Jackson 2.0 AnnotationIntrospector (possibly extension JacksonAnnotationIntrospector ) and use it in Jackson 1.x comments in addition to or instead of JacksonAnnotationIntrospector annotations.

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

Reason 2.0 does not support and does not support 1.x annotations directly, because it will pull additional dependencies and probably cause version conflicts. But this does not stop external libraries from doing this - in fact, if someone wants to contribute, I'm sure the Jackson project will accept the "Jackson 1.x annotations" module for github.

+5
source

Source: https://habr.com/ru/post/1434635/


All Articles