0

Using Jackson to deserialise an array of objects in Java

Java
import com.fasterxml.jackson.databind.ObjectMapper;

ObjectMapper mapper = new ObjectMapper();

MyClass[] myObjects = mapper.readValue(json, MyClass[].class); // array

List<MyClass> myObjects = mapper.readValue(jsonInput, new TypeReference<List<MyClass>>(){}); // list

List<MyClass> myObjects = mapper.readValue(jsonInput, mapper.getTypeFactory().constructCollectionType(List.class, MyClass.class)); // list
add comment
Suggest a different solution or add another example