Tutorial archive
Browse individual tutorials and references.
11 published articles
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.
@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.
@JsonInclude annotation is used to exclude properties during object serialization. By default, all properties of a class are included during serialization.
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.
@JsonAnySetter annotation allows the non-static setter method to deserialize unmapped/unrecognized JSON properties.
@JsonAnyGetter annotation allows key/value pairs of the map to be used as JSON standard properties.
@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.
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.
@JsonProperty annotation is used to change the field name while serializing or deserializing the JSON.
Set property order in JSON.