Tue 08 Nov 2016

JSON

JSON serialization done using Jackson.

Nullable Properties

@JsonSerialize(include = Inclusion.NONNULL)

Polymorphism

http://wiki.fasterxml.com/JacksonPolymorphicDeserialization

@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")

@JsonSubTypes

Annotations

Nice annotations tutorial

You can do:

  • custom serialization for a type
  • ignore a property
  • use a Map as properties
  • behaviour around nulls / default values
  • behaviour around public/protected/private
  • use a constructor instead of setters
  • get things from dependency injection
  • sort out parent/child relationships