These methods are in ObjectNode: the division is such that most read operations are included in JsonNode, but mutations in ObjectNode and ArrayNode.

Note that you can just change first line to be:

ObjectNode jNode = mapper.createObjectNode();
// version ObjectMapper has should return ObjectNode type

or

ObjectNode jNode = (ObjectNode) objectCodec.createObjectNode();
// ObjectCodec is in core part, must be of type JsonNode so need cast
Answer from StaxMan on Stack Overflow
🌐
GitHub
gist.github.com › diegoicosta › f06f61720f02b8c00afddb146ade5cce
Using Jackson to create manually a JsonNode · GitHub
Using Jackson to create manually a JsonNode. GitHub Gist: instantly share code, notes, and snippets.
🌐
Fasterxml
fasterxml.github.io › jackson-databind › javadoc › 2.7 › com › fasterxml › jackson › databind › JsonNode.html
JsonNode (jackson-databind 2.7.0 API)
Method that can be called on Object ... to create, add and return such Array node. If the node method is called on is not Object node, or if property exists and has value that is not Array node, UnsupportedOperationException is thrown · public boolean equals(Comparator<JsonNode> comparator, ...
🌐
Jenkov
jenkov.com › tutorials › java-json › jackson-jsonnode.html
Jackson JsonNode
Instead you create an ObjectNode instance which is a subclass of JsonNode. Here is an example of creating an ObjectNode via the Jackson ObjectMapper createObjectNode() method:
🌐
Attacomsian
attacomsian.com › blog › jackson-json-node-tree-model
Working with Tree Model Nodes in Jackson
October 14, 2022 - Another way of creating a JsonNode object is parsing a JSON string by using the readValue() method from ObjectMapper, as shown below:
🌐
GitHub
github.com › codehaus › jackson › blob › master › src › java › org › codehaus › jackson › JsonNode.java
jackson/src/java/org/codehaus/jackson/JsonNode.java at master · codehaus/jackson
* {@link org.codehaus.jackson.node}, which is in 'mapper' jar · * (whereas this class is in 'core' jar, since it is declared as · * nominal type for operations in {@link ObjectCodec}) */ public abstract class JsonNode · implements Iterable<JsonNode> { protected final static List<JsonNode> NO_NODES = Collections.emptyList(); protected final static List<String> NO_STRINGS = Collections.emptyList(); ·
Author   codehaus
🌐
DEV Community
dev.to › sadiul_hakim › jackson-tutorial-comprehensive-guide-with-examples-2gdj
Jackson Tutorial: Comprehensive Guide with Examples - DEV Community
September 18, 2025 - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; ObjectMapper mapper = new ObjectMapper(); // Create an empty object node ObjectNode personNode = mapper.createObjectNode(); // Add properties to the object personNode.put("name", "John"); personNode.put("age", 30); personNode.put("isStudent", false); // Create an array node ArrayNode hobbiesNode = mapper.createArrayNode(); hobbiesNode.add("Reading"); hobbiesNode.add("Swimming"); hobbiesNo
🌐
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 - import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; public class Main { public static void main(String[] args) { String jsonString = "{\"name\":\"John\",\"age\":30,\"address\":{\"street\":\"123 Main St\",\"city\":\"Anytown\"}}"; ObjectMapper objectMapper = new ObjectMapper(); try { // Parse JSON string into a JsonNode JsonNode rootNode = objectMapper.readTree(jsonString); // Accessing fields String name = rootNode.path("name").asText(); int age = rootNode.path("age").asInt(); String street = rootNode.path("address").path("street").asText(); String city = rootNode.path("address").path("city").asText(); System.out.println("Name: " + name); System.out.println("Age: " + age); System.out.println("Street: " + street); System.out.println("City: " + city); } catch (Exception e) { e.printStackTrace(); } } }
Find elsewhere
🌐
Mkyong
mkyong.com › home › java › jackson tree model examples
Jackson Tree Model examples - Mkyong.com
April 29, 2024 - Update id to 1000 ((ObjectNode) root).put("id", 1000L); // 2. If middle name is empty , update to M ObjectNode nameNode = (ObjectNode) root.path("name"); if (nameNode.path("middle").asText().isEmpty()) { nameNode.put("middle", "M"); } // Adding new data // 3. Create a new field in nameNode nameNode.put("nickname", "mkyong"); // remove data // 4. Remove last field in nameNode nameNode.remove("last"); // 5. Create a new ObjectNode and add to root ObjectNode positionNode = mapper.createObjectNode(); positionNode.put("name", "Developer"); positionNode.put("years", 10); ((ObjectNode) root).set("pos
🌐
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 ...
🌐
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).
🌐
Tabnine
tabnine.com › home page › code › java › com.fasterxml.jackson.databind.jsonnode
com.fasterxml.jackson.databind.JsonNode java code examples | Tabnine
final String json = "{\"objects\" : [\"One\", \"Two\", \"Three\"]}"; final JsonNode arrNode = new ObjectMapper().readTree(json).get("objects"); if (arrNode.isArray()) { for (final JsonNode objNode : arrNode) { System.out.println(objNode); } } Base class for all JSON nodes, which form the basis of JSON Tree Model that Jackson implements.
🌐
Adobe Developer
developer.adobe.com › experience-manager › reference-materials › cloud-service › javadoc › com › fasterxml › jackson › databind › JsonNode.html
JsonNode (The Adobe Experience Manager SDK 2022.11.9850.20221116T162329Z-220900)
comparator - Object called to compare two scalar JsonNode instances, and return either 0 (are equals) or non-zero (not equal) ... Method that will produce (as of Jackson 2.10) valid JSON using default settings of databind, as String.
🌐
Fasterxml
fasterxml.github.io › jackson-databind › javadoc › 2.8 › com › fasterxml › jackson › databind › JsonNode.html
JsonNode (jackson-databind 2.8.0 API)
Method that can be called on Object ... to create, add and return such Array node. If the node method is called on is not Object node, or if property exists and has value that is not Array node, UnsupportedOperationException is thrown · public boolean equals(Comparator<JsonNode> comparator, ...
🌐
Makeseleniumeasy
makeseleniumeasy.com › 2020 › 05 › 16 › rest-assured-tutorial-27-how-to-create-json-array-using-jackson-api-objectmapper-createarraynode
REST Assured Tutorial 27 – How To Create JSON Array Using Jackson API – ObjectMapper – CreateArrayNode()
Since JSON Array is iterable, we can retrieve a JSON object using its index. // To get json array element using index JsonNode firstElement = parentArray.get(0); System.out.println(objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(firstElement)); size() method can be used to ...
🌐
Apps Developer Blog
appsdeveloperblog.com › home › java › java json › modify jsonnode with java jackson
Modify JsonNode with Java Jackson - Apps Developer Blog
August 12, 2022 - class Test { public static void main(String[] args) throws IOException { ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.createObjectNode(); ((ObjectNode) jsonNode).put("key1", "value1"); System.out.println(jsonNode.toPrettyString()); } }
🌐
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.