Jackson annotations give you precise control over how your Java objects map to JSON and back. Rather than relying solely on field names, you can rename properties, ignore specific fields, handle nulls, format dates, and much more — all without writing a single custom serialiser. This guide covers every annotation you will encounter in real projects, with concrete examples for each.
@JsonProperty — Rename a Field in JSON
Use @JsonProperty when the JSON key must differ from the Java field name — for example, when consuming a third-party API that uses snake_case.
public class OrderSummary {
@JsonProperty("order_id") // JSON key: order_id
private Long orderId;
@JsonProperty("customer_name") // JSON key: customer_name
private String customerName;
// Getters and setters
}
// Serialise
{"order_id":1001,"customer_name":"Alice"}
// Deserialise: JSON with "order_id" maps correctly to the orderId field
Continue reading Jackson Annotations Cheat Sheet: Every Annotation You Need With Examples