A slight variation on Richards answer but readTree can take a string so you can simplify it to:

ObjectMapper mapper = new ObjectMapper();
JsonNode actualObj = mapper.readTree("{\"k1\":\"v1\"}");
Answer from slashnick on Stack Overflow
🌐
Javadoc.io
javadoc.io › doc › com.fasterxml.jackson.core › jackson-databind › latest › com › fasterxml › jackson › databind › JsonNode.html
JsonNode - jackson-databind 2.21.2 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.2 · https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.21.2 · package-list path (used for javadoc generation ...
🌐
Fasterxml
fasterxml.github.io › jackson-databind › javadoc › 2.8 › com › fasterxml › jackson › databind › JsonNode.html
JsonNode (jackson-databind 2.8.0 API)
public abstract class JsonNode extends JsonSerializable.Base implements TreeNode, Iterable<JsonNode> Base class for all JSON nodes, which form the basis of JSON Tree Model that Jackson implements.
🌐
Baeldung
baeldung.com › home › json › jackson › working with tree model nodes in jackson
Working with Tree Model Nodes in Jackson | Baeldung
January 8, 2024 - This tutorial will focus on working with tree model nodes in Jackson. We’ll use JsonNode for various conversions as well as adding, modifying, and removing nodes.
🌐
Medium
medium.com › @salvipriya97 › jsonnode-explained-with-examples-d0c05324f61d
JsonNode explained with examples. What is JsonNode in Java? | by Priya Salvi | Medium
July 2, 2024 - JsonNode is a class provided by the Jackson library that represents a node in a JSON tree structure. It is part of Jackson's Tree Model, which allows for parsing, manipulating, and generating JSON content in a hierarchical tree form.
🌐
Attacomsian
attacomsian.com › blog › jackson-convert-java-object-to-json-node
Convert Java Object to JsonNode using Jackson
October 14, 2022 - A short tutorial to learn how to convert a Java Object or a Map to a JsonNode Object using Jackson.
🌐
Maven Repository
mvnrepository.com › artifact › com.fasterxml.jackson.core › jackson-databind
Maven Repository: com.fasterxml.jackson.core » jackson-databind
2 weeks ago - Jackson Core is a core library for Jackson that provides low-level streaming JSON input/output functionality.
Find elsewhere
🌐
Jenkov
jenkov.com › tutorials › java-json › jackson-jsonnode.html
Jackson JsonNode
The Jackson JsonNode class is the Jackson tree object model for JSON. Jackson can read JSON into an object graph (tree) of JsonNode objects. Jackson can also write a JsonNode tree to JSON.
🌐
Readthedocs
jse.readthedocs.io › en › latest › utils › jackson › jacksonJsonNodeForEach.html
Jackson JsonNode.forEach() with Java 8 Consumer — Java Repositories 1.0 documentation
JsonFactory jsonFactory = new JsonFactory(); JsonParser jp = jsonFactory.createJsonParser(new File("D:/cp/info.json")); jp.setCodec(new ObjectMapper()); JsonNode jsonNode = jp.readValueAsTree(); Consumer<JsonNode> data = (JsonNode node) -> System.out.println(node.asText()); jsonNode.forEach(data); JacksonJsonNodeForEachTest ·
🌐
Javadoc.io
javadoc.io › doc › com.fasterxml.jackson.core › jackson-databind › 2.8.1 › com › fasterxml › jackson › databind › class-use › JsonNode.html
JsonNode - jackson-databind 2.8.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.8.1 · https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.8.1 · package-list path (used for javadoc generation ...
🌐
Red Hat
access.redhat.com › webassets › avalon › d › red-hat-jboss-enterprise-application-platform › 7.1.beta › javadocs › com › fasterxml › jackson › databind › JsonNode.html
JsonNode (Red Hat JBoss Enterprise Application Platform 7.1.0.Beta1 public API)
public abstract class JsonNode extends JsonSerializable.Base implements TreeNode, Iterable<JsonNode> Base class for all JSON nodes, which form the basis of JSON Tree Model that Jackson implements.
🌐
Java Code Geeks
javacodegeeks.com › home › enterprise java
Simplified Json Array Operations with JsonNode in Jackson
May 6, 2024 - Learn efficient "Simplified Array Operations on JsonNode in Jackson" for streamlined JSON handling in Java. Discover techniques to work with JSON arrays seamlessly using Jackson's JsonNode abstraction without the need for typecasting.
🌐
TutorialsPoint
tutorialspoint.com › how-to-access-the-json-fields-arrays-and-nested-objects-of-jsonnode-in-java
How to access the JSON fields, arrays and nested objects of JsonNode in Java?
May 13, 2025 - We can access a field, array or ... value of the node to a Java int using the asInt() method of JsonNode class. JSON node is a class in the Jackson library that represents a JSON object....
🌐
DEV Community
dev.to › abharangupta › dive-into-jackson-for-json-in-java-understanding-jsonnode-arraynode-and-objectmapper-30g4
Dive into Jackson for JSON in Java: Understanding JsonNode, ArrayNode, and ObjectMapper - DEV Community
October 22, 2024 - ObjectMapper is Jackson's main helper. It's the one that translates between JSON and Java. readTree() reads the JSON and converts it into a JsonNode object.
🌐
Codemia
codemia.io › knowledge-hub › path › how_to_modify_jsonnode_in_java
How to modify JsonNode in Java?
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises
🌐
Baeldung
baeldung.com › home › json › jackson › jackson – marshall string to jsonnode
Jackson - Marshall String to JsonNode | Baeldung
June 28, 2023 - This quick tutorial will show how to use Jackson 2 to convert a JSON String to a JsonNode (com.fasterxml.jackson.databind.JsonNode).
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