Java TextNode-class And Method Code Example

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.TextNode;

public class Example {
    public static void main(String[] args) {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode textNode = new TextNode("Hello World!");

        // textNode is an instance of TextNode
        System.out.println(textNode.textValue()); // prints "Hello World!"

This example shows how to create an instance of the TextNode class, which is a special type of JsonNode that represents a JSON string value. The TextNode class has a constructor that takes a String value, which can be passed as a parameter to create a TextNode. Once obtained, you can get the text value of the node using the textValue() method.

You can also use TextNode.valueOf(String) method to create TextNode, which is a static factory method that creates and returns a new instance of TextNode with the specified text value.