CodeKru
Menu

Tutorial archive

Category: <span>Jackson Annotations</span>

Browse individual tutorials and references.

11 published articles

Java

How to accept a single value as an array in JSON using Java?

Problem Statement Sometimes, we might get two types of values for a single key - a single value or an array of those values, but we don't know which will come and when.

Java

@JsonFormat Jackson Annotation

@JsonFormat annotation is used to format the fields or properties while serializing. It is most commonly used to format the Date/Time properties but has some other uses, which we will discuss in this post.

Java

@JsonInclude Jackson Annotation

@JsonInclude annotation is used to exclude properties during object serialization. By default, all properties of a class are included during serialization.

Java

Java Optional with Jackson

This post will explain how to serialize/deserialize the java optional type field using Jackson. So, let's first look at the problem, and then we will move on to its solution.

Java

@JsonAnySetter Jackson Annotation

@JsonAnySetter annotation allows the non-static setter method to deserialize unmapped/unrecognized JSON properties.

Java

@JsonAnyGetter Jackson Annotation

@JsonAnyGetter annotation allows key/value pairs of the map to be used as JSON standard properties.

Java

@JsonValue Jackson Annotation

@JsonValue allows annotated field or getter method to be used as a single value for object serialization. This overrides the usual method of showing properties as JSON output in serialization.

Java

@JsonRawValue Jackson Annotation

Let's first discuss what problem does @JsonRawValue solves? Let's consider a nested JSON as shown below. Now, what if I want to make this JSON from an object.

Java

@JsonProperty Jackson Annotation

@JsonProperty annotation is used to change the field name while serializing or deserializing the JSON.

Java

@JsonPropertyOrder Jackson Annotation

Set property order in JSON.