Jackson

Usefull Annotations

  • @JsonIncludeProperties: Ignore all properties except listed
  • @JsonProperty("my_name"): Custom name of the JSON key
  • @JsonIgnore: Ignore the json property below

Wrapping the Obejct in Another JSON Object

To do that, use these annotations above the class.

@JsonTypeName(value = "action")
@JsonTypeInfo(include=As.WRAPPER_OBJECT, use=Id.NAME)

If you do not care about the name, you can skip the @JsonTypeName annotation.

Written with StackEdit.