Home » Jackson Change Name of the Field

Jackson Change Name of the Field

by Online Tutorials Library

Jackson Change Name of the Field

When we serialize a Java Object, we need to change the name of a specific field for mapping it with another JSON property. It is one of the most used and important concepts of Jackson to learn and understand.

In order to change the field name, we use the @JsonProperty annotation. In the annotation constructor, we pass the name of the property.

Let’s take an example to understand how we can use @JsonProperty annotation to change the name of the field for serialization.

ChangeNameOfFieldExample.java

Output:

Jackson Change Name of the Field


You may also like