First create a mapper :

import com.fasterxml.jackson.databind.ObjectMapper;// in play 2.3
ObjectMapper mapper = new ObjectMapper();

As Array:

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

As List:

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

Another way to specify the List type:

List<MyClass> myObjects = mapper.readValue(jsonInput, mapper.getTypeFactory().constructCollectionType(List.class, MyClass.class));
Answer from Programmer Bruce on Stack Overflow
🌐
Baeldung
baeldung.com › home › json › jackson › jackson – unmarshall to collection/array
Jackson - Unmarshall to Collection/Array | Baeldung
April 26, 2024 - Or we can use the overloaded readValue method that accepts a JavaType: @Test public void givenJsonArray_whenDeserializingAsListWithJavaTypeHelp_thenCorrect() throws JsonParseException, JsonMappingException, IOException { ObjectMapper mapper = new ObjectMapper(); List<MyDto> listOfDtos = Lists.newArrayList( new MyDto("a", 1, true), new MyDto("bc", 3, false)); String jsonArray = mapper.writeValueAsString(listOfDtos); CollectionType javaType = mapper.getTypeFactory() .constructCollectionType(List.class, MyDto.class); List<MyDto> asList = mapper.readValue(jsonArray, javaType); assertThat(asList.get(0), instanceOf(MyDto.class)); }
🌐
Tabnine
tabnine.com › home › code library
https://www.tabnine.com/code/java/methods/com.fast...
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
🌐
Medium
medium.com › @jamokoy397 › jackson-magic-deserializing-non-existent-lists-into-empty-lists-java-objectmapper-300ede79fa04
Jackson Magic: Deserializing Non-Existent Lists into Empty Lists (Java, ObjectMapper) | by Jamokoy Lancey | Medium
October 21, 2024 - class EmptyListDeserializerTest { final ObjectMapper objectMapper = new ObjectMapper(); { objectMapper.configOverride(List.class) .setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY, Nulls.AS_EMPTY)); } @Test void test2() throws JsonProcessingException { final var result = objectMapper.readValue("null", new TypeReference<List<MyClass>>() {}); assertThat(result).isEmpty(); } @Test void test3() throws JsonProcessingException { final var json = """ [{ "name": "John Doe", "address": null }] """; final var result = objectMapper.readValue(json, new TypeReference<List<MyComplexClass>>() {});
🌐
Baeldung
baeldung.com › home › json › jackson › intro to the jackson objectmapper
Intro to the Jackson ObjectMapper | Baeldung
December 9, 2025 - String jsonCarArray = "[{ \"color\" : \"Black\", \"type\" : \"BMW\" }, { \"color\" : \"Red\", \"type\" : \"FIAT\" }]"; ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY, true); Car[] cars = objectMapper.readValue(jsonCarArray, Car[].class); // print cars ... String jsonCarArray = "[{ \"color\" : \"Black\", \"type\" : \"BMW\" }, { \"color\" : \"Red\", \"type\" : \"FIAT\" }]"; ObjectMapper objectMapper = new ObjectMapper(); List<Car> listCar = objectMapper.readValue(jsonCarArray, new TypeReference<List<Car>>(){}); // print cars
🌐
Stack Abuse
stackabuse.com › converting-json-array-to-a-java-array-or-list
Convert JSON Array to a Java Array or List with Jackson
September 8, 2020 - We don't always deal with JSON in String format. Oftentimes, the contents come from a File. Thankfully, Jackson makes this task as easy as the last one, we just provide the File to the readValue() method: final ObjectMapper objectMapper = new ObjectMapper(); List<Language> langList = objectMapper.readValue( new File("langs.json"), new TypeReference<List<Language>>(){}); langList.forEach(x -> System.out.println(x.toString()));
Top answer
1 of 6
104

Something which is much shorter:

mapper.readValue(jsonString, new TypeReference<List<EntryType>>() {});

Where EntryType is a reference to type you would like to hold within collection. It might be any Java class. For example to read JSON representation such as ["a", "b", "c"] second argument to mapper should be new TypeReference<List<String>>() {}

2 of 6
74

If you need to map the incoming json to your List you can do like this

String jsonString = ...; //Your incoming json string
ObjectMapper mapper = new ObjectMapper();
Class<?> clz = Class.forName(yourTypeString);
JavaType type = mapper.getTypeFactory().constructCollectionType(List.class, clz);
List <T> result = mapper.readValue(jsonString, type);

Edit

Something like this, completly untested and never done

public Message<T> deserialize(JsonParser jsonParser, DeserializationContext arg1)
    throws IOException, JsonProcessingException {
    ObjectMapper mapper = new ObjectMapper();
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);

    JsonNode timeStamp = node.get("time");
    Timestamp time = mapper.readValue(timeStamp, Timestamp.class);
    JsonNode restAction = node.get("action");
    RestAction action = mapper.readValue(restAction, RestAction.class);
    String type = node.get("type").getTextValue();
    Class<?> clz = Class.forName(type);
    JsonNode list = node.get("data");
    JavaType listType = mapper.getTypeFactory().constructCollectionType(List.class,   clz);
    List <T> data = mapper.readValue(list, listType);

    Message<T> message = new Message<T>;
    message.setTime(time);
    message.setAction(action);
    message.setType(type);
    message.setData(data);

    return message;
}
🌐
Apps Developer Blog
appsdeveloperblog.com › home › java › java json › convert json array to java list using jackson
Convert JSON Array to Java List using Jackson - Apps Developer Blog
March 22, 2024 - Assuming you have a JSON array string stored in a variable called “jsonArrayString”, you can convert it to a list of Person objects as shown below: ObjectMapper objectMapper = new ObjectMapper(); List<Person> personList = objectMapper.readValue(jsonArrayString, typeReference); In the above ...
🌐
GitHub
github.com › FasterXML › jackson-databind › issues › 2095
Deserialize list of array failed with enableDefaultTyping · Issue #2095 · FasterXML/jackson-databind
July 23, 2018 - ObjectMapper objectMapper = new ObjectMapper(); objectMapper = objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, JsonTypeInfo.As.PROPERTY); List<String[]> list = new ArrayList<>(); list.add(new String[] { "test" }); String s = objectMapper.writeValueAsString(list); // [["[Ljava.lang.String;",["test"]]] List<String[]> list2 = objectMapper.readValue(s, new TypeReference<List<String[]>>() { }); System.out.println(Arrays.equals(list.get(0), list2.get(0)));
Author: FasterXML
Find elsewhere
🌐
Mkyong
mkyong.com › home › java › how to parse json array with jackson
How to parse JSON Array with Jackson | mkyong.com
April 23, 2024 - convert JSON array to List List<Person> person2 = mapper.readValue(jsonArray, new TypeReference<>() { }); person2.forEach(System.out::println); } } ... Person{name='mkyong', age=42} Person{name='ah pig', age=20} Person{name='mkyong', age=42} Person{name='ah pig', age=20} ... package com.mkyong.json.jackson; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.mkyong.json.model.Person; import java.util.Arrays; import java.util.List; public class JsonArrayToObjectExample2 { public static void main(String[] args) throws JsonProcessingException { List<Person> list = Arrays.asList( new Person("mkyong", 42), new Person("ah pig", 20) ); ObjectMapper mapper = new ObjectMapper(); String result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(list); System.out.println(result); } }
🌐
Jenkov
jenkov.com › tutorials › java-json › jackson-objectmapper.html
Jackson ObjectMapper
Notice the TypeReference parameter passed to readValue(). This parameter tells Jackson to read a List of Car objects. The Jackson ObjectMapper can also read a Java Map from a JSON string. This can be useful if you do not know ahead of time the exact JSON structure that you will be parsing.
🌐
Readthedocs
jse.readthedocs.io › en › latest › utils › jackson › jacksonObjectMapper.html
Jackson ObjectMapper — Java Repositories 1.0 documentation
Car car = objectMapper.readValue(new URL("file:src/test/resources/json_car.json"), Car.class); String json = "{ \"color\" : \"Black\", \"type\" : \"FIAT\" }"; JsonNode jsonNode = objectMapper.readTree(json); String color = jsonNode.get("color").asText(); // Output: color -> Black · String jsonCarArray = "[{ \"color\" : \"Black\", \"type\" : \"BMW\" }, { \"color\" : \"Red\", \"type\" : \"FIAT\" }]"; List<Car> listCar = objectMapper.readValue(jsonCarArray, new TypeReference<List<Car>>(){});
🌐
Makeinjava
makeinjava.com › home › convert list of objects to/from json in java (jackson objectmapper/ example)
Convert list of objects to/from JSON in java (jackson objectmapper/example)
January 1, 2024 - Convert List of Person objects to JSON String arrayToJson = objectMapper.writeValueAsString(personList); System.out.println("1. Convert List of person objects to JSON :"); System.out.println(arrayToJson); //2. Convert JSON to List of Person objects //Define Custom Type reference for List<Person> type TypeReference<List<Person>> mapType = new TypeReference<List<Person>>() {}; List<Person> jsonToPersonList = objectMapper.readValue(arrayToJson, mapType); System.out.println("\n2.
🌐
Java Code Geeks
examples.javacodegeeks.com › home › java development › core java › json › jackson
Jackson ObjectMapper - Examples Java Code Geeks - 2026
June 19, 2020 - String countryStr = "{\"name\":\"India\",\"population\":135260000000," + "\"numberOfProvinces\":29,\"developed\":true}"; Map jsonStringToMap = objectMapper.readValue(countryStr, new TypeReference<Map>() { }); System.out.println("Country as a Map : " + jsonStringToMap); ... Similarly, a JSON object that contains an array can be deserialized into a Java object of the type java.util.List.
🌐
Java Guides
javaguides.net › 2019 › 04 › jackson-list-set-and-map-serialization-and-deseialization-in-java-example.html
Jackson - List, Set and Map Serialization and Deserialization in Java Examples
April 24, 2019 - ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); String json = "[ \"C\", \"C++\", \"Java\", \"Java EE\", \"Python\", \"Scala\", \"JavaScript\" ]"; List < String > progLangs = new ArrayList < > (); progLangs = mapper.readValue(json, List.class); for (Iterator < String > iterator = progLangs.iterator(); iterator.hasNext();) { String progLang = (String) iterator.next(); System.out.println(progLang); } } }
🌐
Stack Abuse
stackabuse.com › definitive-guide-to-jackson-objectmapper-serialize-and-deserialize-java-objects
Definitive Guide to Jackson ObjectMapper - Serialize and Deserialize Java Objects
October 27, 2023 - String healthWorkersJsonArray = "[{\"id\":1,\"name\":\"RehamMuzzamil\",\"qualification\":\"MBBS\",\"yearsOfExperience\":1.5},{\"id\":2,\"name\":\"MichaelJohn\",\"qualification\":\"FCPS\",\"yearsOfExperience\":5}]"; ObjectMapper objectMapper = new ObjectMapper(); HealthWorker[] healthWorkerArray = objectMapper.readValue(healthWorkersJsonArray, HealthWorker[].class); // OR HealthWorker[] healthWorkerArray = objectMapper.readValue(jsonKeyValuePair, new TypeReference<HealthWorker[]>(){}); Though, since arrays are messy to work with - you can just as easily convert the JSON array into a List of obj
🌐
Java Guides
javaguides.net › 2023 › 10 › java-jackson-objectmapper-readvalue.html
Java Jackson ObjectMapper readValue()
October 26, 2023 - } // MainApp.java import com.fasterxml.jackson.databind.ObjectMapper; public class MainApp { public static void main(String[] args) { String jsonString = "{\"id\":1,\"name\":\"John Doe\",\"email\":\"john.doe@example.com\"}"; ObjectMapper objectMapper = new ObjectMapper(); try { User user = objectMapper.readValue(jsonString, User.class); System.out.println("User ID: " + user.getId()); System.out.println("User Name: " + user.getName()); System.out.println("User Email: " + user.getEmail()); } catch (Exception ex) { ex.printStackTrace(); } } }