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

Java json – jackson Mix- In Annotations

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

  1. 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.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top