Java json – jackson Mix- In Annotations

Also see json simple org.json

Annotations are a great way to manage serialization and deserialization in Jackson. However, what do you do if you want to annotate a third party class, or if you dont want to tightly couple your POJOs to jackson annotations. This is where Mix-in comes into play. You define a mix-in abstract class that is kind of a proxy to the actual class. Annotations are then definied over this proxy class

Jackson Mix-In Example

The Bird class

The Mix-in class

One thought on “Java json – jackson Mix- In Annotations

  • July 11, 2017 at 1:55 pm
    Permalink

    Thanks for great tutorials.
    according to documentation “addMixInAnnotations()” method which returns void, is replaced by a fluent form of the method; addMixIn(Class, Class) which returns ObjectMapper; since 2.5.
    This method is used in SerializeExample3 class above.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *