Acquire an ObjectReader with ObjectMapper#readerFor(TypeReference) using a TypeReference describing the typed collection you want. Then use ObjectReader#readValue(JsonNode) to parse the JsonNode (presumably an ArrayNode).

For example, to get a List<String> out of a JSON array containing only JSON strings

CopyObjectMapper mapper = new ObjectMapper();
// example JsonNode
JsonNode arrayNode = mapper.createArrayNode().add("one").add("two");
// acquire reader for the right type
ObjectReader reader = mapper.readerFor(new TypeReference<List<String>>() {
});
// use it
List<String> list = reader.readValue(arrayNode);
Answer from Sotirios Delimanolis on Stack Overflow
🌐
GitHub
github.com › junit-pioneer › junit-pioneer › issues › 654
Convert ArrayNode to List · Issue #654 · junit-pioneer/junit-pioneer
July 28, 2022 - Error converting parameter at index 0: No implicit conversion to convert object of type com.fasterxml.jackson.databind.node.ArrayNode to type java.util.List org.junit.jupiter.api.extension.ParameterResolutionException: Error converting parameter at index 0: No implicit conversion to convert ...
Author   bartsimp
🌐
javathinking
javathinking.com › blog › convert-arraynode-to-list-java
Converting ArrayNode to List in Java — javathinking.com
It extends ContainerNode and provides methods to manipulate the array elements, such as adding, removing, and accessing elements. An ArrayNode can hold different types of JSON values like strings, numbers, booleans, and even other JSON objects or arrays. In Java, List is an interface from the Java Collections Framework.
Discussions

java - Jackson JsonNode to typed Collection - Stack Overflow
If it were a json string I could ... JavaType) which feels wrong on account of its accepting any POJO for conversion. Is there another "correct" way or is it one of these? ... Save this answer. Show activity on this post. Acquire an ObjectReader with ObjectMapper#readerFor(TypeReference) using a TypeReference describing the typed collection you want. Then use ObjectReader#readValue(JsonNode) to parse the JsonNode (presumably an ArrayNode). For example, to get a List out ... More on stackoverflow.com
🌐 stackoverflow.com
json - Converting Jackson JsonNode array to Java List<String> - Stack Overflow
I hava a Jackson JsonNode (v2.6.3) which has a json array as one of its fields and I'm looking to convert that array to a java List Currently im doing the following problem is line 3: JsonNode More on stackoverflow.com
🌐 stackoverflow.com
java - Jackson Json: how to convert array to JsonNode and ObjectNode? - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
java - Jackson how to transform JsonNode to ArrayNode without casting? - Stack Overflow
Yes, the Jackson manual parser design is quite different from other libraries. In particular, you will notice that JsonNode has most of the functions that you would typically associate with array nodes from other APIs. As such, you do not need to cast to an ArrayNode to use. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Tabnine
tabnine.com › home page › code › java › com.fasterxml.jackson.databind.node.arraynode
com.fasterxml.jackson.databind.node.ArrayNode.forEach java code examples | Tabnine
public Collection<OpenstackRouter> getRouters() { Invocation.Builder builder = getClientBuilder(neutronUrl + PATH_ROUTERS); String response = builder.accept(MediaType.APPLICATION_JSON_TYPE). header(HEADER_AUTH_TOKEN, getToken()).get(String.class); ObjectMapper mapper = new ObjectMapper(); List<OpenstackRouter> openstackRouters = Lists.newArrayList(); try { ObjectNode node = (ObjectNode) mapper.readTree(response); ArrayNode routerList = (ArrayNode) node.path(PATH_ROUTERS); OpenstackRouterCodec openstackRouterCodec = new OpenstackRouterCodec(); routerList.forEach(r -> openstackRouters .add(openstackRouterCodec.decode((ObjectNode) r, null))); } catch (IOException e) { log.warn("getRouters()", e); } log.debug("router response:" + response); openstackRouters.forEach(r -> log.debug("router ID: {}", r.id())); return openstackRouters; }
Top answer
1 of 3
89

Acquire an ObjectReader with ObjectMapper#readerFor(TypeReference) using a TypeReference describing the typed collection you want. Then use ObjectReader#readValue(JsonNode) to parse the JsonNode (presumably an ArrayNode).

For example, to get a List<String> out of a JSON array containing only JSON strings

CopyObjectMapper mapper = new ObjectMapper();
// example JsonNode
JsonNode arrayNode = mapper.createArrayNode().add("one").add("two");
// acquire reader for the right type
ObjectReader reader = mapper.readerFor(new TypeReference<List<String>>() {
});
// use it
List<String> list = reader.readValue(arrayNode);
2 of 3
13

If an Iterator is more useful...

...you can also use the elements() method of ArrayNode. Example see below.

sample.json

Copy{
    "first": [
        "Some string ...",
        "Some string ..."
    ],
    "second": [
        "Some string ..."
    ]
}

So, the List<String> is inside one of the JsonNodes.

Java

When you convert that inner node to an ArrayNode you can use the elements() method, which returns an Iterator of JsonNodes.

CopyFile file = new File("src/test/resources/sample.json");
ObjectMapper mapper = new ObjectMapper();
JsonNode jsonNode = mapper.readTree(file);
ArrayNode arrayNode = (ArrayNode) jsonNode.get("first");
Iterator<JsonNode> itr = arrayNode.elements();
// and to get the string from one of the elements, use for example...
itr.next().asText();

New to Jackson Object Mapper?

I like this tutorial: https://www.baeldung.com/jackson-object-mapper-tutorial

Update:

You can also use .iterator() method of ArrayNode. It is the same:

Same as calling .elements(); implemented so that convenience "for-each" loop can be used for looping over elements of JSON Array constructs.

from the javadocs of com.fasterxml.jackson.core:jackson-databind:2.11.0

🌐
Adobe Developer
developer.adobe.com › experience-manager › reference-materials › 6-5 › javadoc › com › fasterxml › jackson › databind › node › ArrayNode.html
ArrayNode (The Adobe AEM Quickstart and Web Application.)
public ArrayNode(JsonNodeFactory nf, java.util.List<JsonNode> children) Since: 2.7 · public ArrayNode deepCopy() Description copied from class: JsonNode · Method that can be called to get a node that is guaranteed not to allow changing of this node through mutators on this node or any of its children.
🌐
Java Tips
javatips.net › api › com.fasterxml.jackson.databind.node.arraynode
Java Examples for com.fasterxml.jackson.databind.node.ArrayNode
*/ protected List<Point> toPoints(ArrayNode node) { if (node == null) { return Collections.emptyList(); } List<Point> points = new ArrayList<Point>(node.size()); for (JsonNode coordinatePair : node) { if (coordinatePair.isArray()) { points.add(toPoint((ArrayNode) coordinatePair)); } } return points; }
Find elsewhere
🌐
Java Tips
javatips.net › api › org.codehaus.jackson.node.arraynode
Java Examples for org.codehaus.jackson.node.ArrayNode
@Override public Set<String> getImports(JavaClass klass) { final Set<String> imports = new HashSet<String>(); imports.add("org.codehaus.jackson.JsonNode"); imports.add("org.codehaus.jackson.node.ObjectNode"); if (klass.isUsedAsResult()) { imports.add("org.codehaus.jackson.node.ArrayNode"); imports.add("java.util.List"); imports.add("java.util.ArrayList"); } if (klass.isMultiType()) { for (JavaAttribute member : klass.getMembers()) { if (!member.isEnum()) { if ("boolean".equals(member.getType().getName())) { imports.add("org.codehaus.jackson.node.BooleanNode"); } if ("string".equals(member.getT
🌐
Fasterxml
fasterxml.github.io › jackson-databind › javadoc › 2.7 › com › fasterxml › jackson › databind › node › ArrayNode.html
ArrayNode (jackson-databind 2.7.0 API)
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)
🌐
Fasterxml
fasterxml.github.io › jackson-core › javadoc › 1.9 › org › codehaus › jackson › node › ArrayNode.html
ArrayNode (Jackson JSON Processor)
Method that will construct an ArrayNode and add it as a field of this ObjectNode, replacing old value, if any. ... Method that will construct an ObjectNode and add it at the end of this array node. ... Method that will construct a POJONode and add it at the end of this array node.
🌐
Baeldung
baeldung.com › home › json › jackson › convert json array to java list
Convert JSON Array to Java List | Baeldung
August 13, 2025 - Then, we use the readValue() method of the ObjectMapper object to convert the JSON array String to a List. Similar to the assertion discussed previously, finally, we compare a specific field from the String JSON array to the jacksonList ...
🌐
Javadoc.io
javadoc.io › doc › com.fasterxml.jackson.core › jackson-databind › latest › com › fasterxml › jackson › databind › node › ArrayNode.html
ArrayNode - jackson-databind 2.21.1 javadoc
Bookmarks · Latest version of com.fasterxml.jackson.core:jackson-databind · https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind · Current version 2.21.1 · https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.21.1 · package-list path (used for javadoc generation ...
🌐
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 - In this article, we'll convert a JSON array into a Java Array and Java List using Jackson.
🌐
Adobe Developer
developer.adobe.com › experience-manager › reference-materials › cloud-service › javadoc › com › fasterxml › jackson › databind › node › ArrayNode.html
ArrayNode (The Adobe Experience Manager SDK 2022.11.9850.20221116T162329Z-220900)
public ArrayNode​(JsonNodeFactory nf, java.util.List<JsonNode> children) Since: 2.7 · public ArrayNode deepCopy() Description copied from class: JsonNode · Method that can be called to get a node that is guaranteed not to allow changing of this node through mutators on this node or any of its children.
🌐
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 Array objects Person[] person1 = mapper.readValue(jsonArray, Person[].class); for (Person p : person1) { System.out.println(p); } // 2. 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
🌐
Java Code Geeks
javacodegeeks.com › home › enterprise java
Simplified Json Array Operations with JsonNode in Jackson
May 6, 2024 - Let’s dive into these methods step by step to enhance your JSON manipulation skills in Java. Jackson is a popular Java library used for JSON processing. JsonNode is a fundamental abstraction representing a node in the JSON tree structure, capable of representing various JSON types such as objects, arrays, strings, numbers, and more. When working with JSON arrays ([]), the ArrayNode class in Jackson is especially useful for handling Simplified Array Operations on JsonNode in Jackson, enabling efficient manipulation and traversal of JSON arrays within Java applications.
🌐
Fasterxml
fasterxml.github.io › jackson-databind › javadoc › 2.6 › com › fasterxml › jackson › databind › node › ArrayNode.html
ArrayNode (jackson-databind 2.6.0 API)
Method that can be used for efficient type detection when using stream abstraction for traversing nodes. Will return the first JsonToken that equivalent stream event would produce (for most nodes there is just one token but for structured/container types multiple)
🌐
TutorialsPoint
tutorialspoint.com › how-to-convert-jsonnode-to-arraynode-using-jackson-api-in-java
How to convert JsonNode to ArrayNode using Jackson API in Java?
A JsonNode is a base class for all JSON nodes that forms the JSON Tree Model whereas ArrayNode is a node class that represents an array mapped from JSON content. We can convert or translate JsonNode to ArrayNode by typecasting the ArrayNode to retrieve the values using the readTree() method of ObjectMapper class and get() method for accessing the value of a specified element of an array node.