How-to articles, tricks, and solutions about JACKSON

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

This error is usually encountered when trying to parse a JSON string that does not start with a JSON array, but rather a JSON object.

Converting JSON data to Java object

To convert JSON data to a Java object, you can use the fromJson method of the Gson class.

Date format Mapping to JSON Jackson

You can use the @JsonFormat annotation to specify the format of date fields in a JSON payload when serializing or deserializing using Jackson.

How to convert the following json string to java object?

To convert a JSON string to a Java object, you can use the fromJson method of the Gson class.

How to tell Jackson to ignore a field during serialization if its value is null?

There are a few ways to tell Jackson to ignore a field during serialization if its value is null. One way is to use the @JsonInclude annotation with the Include.NON_NULL value on the field or class level.

How to use Jackson to deserialise an array of objects

Jackson is a powerful Java library for processing JSON data. You can use Jackson to deserialize an array of objects by following these steps:

Ignoring new fields on JSON objects using Jackson

If you want to ignore new fields on JSON objects when using Jackson, you can use the @JsonIgnoreProperties annotation on your Java object.

Jackson with JSON: Unrecognized field, not marked as ignorable

If you are using the Jackson library to parse JSON in Java and you get the error "Unrecognized field, not marked as ignorable", it means that you are trying to parse a JSON object that has a field that is not recognized by your Java object.

Only using @JsonIgnore during serialization, but not deserialization

If you want to use the @JsonIgnore annotation to ignore a field during serialization but not during deserialization, you can use the @JsonIgnoreProperties annotation and set its writeOnly property to true.

Serializing with Jackson (JSON) - getting "No serializer found"?

If you are getting the error "No serializer found" when trying to serialize an object to JSON using Jackson, it usually means that Jackson does not know how to serialize one or more fields in the object.

When is the @JsonProperty property used and what is it used for?

The @JsonProperty annotation is used to specify the property name in a JSON object when serializing or deserializing a Java object using the Jackson library.