Java NullNode-class And Method Code Example


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

public class Example {
    public static void main(String[] args) {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode nullNode = NullNode.getInstance();

        // nullNode is an instance of NullNode
        System.out.println(nullNode.isNull()); // prints "true"
    }
}

This example shows how to create an instance of the NullNode class, which is a special type of JsonNode that represents a JSON null value. The NullNode class has a singleton instance, which can be obtained using the NullNode.getInstance() method. Once obtained, you can check if a JsonNode is a null node using the isNull() method.

Note that, MissingNode represents a missing value in a JSON tree, it is not the same as null value, which is represented by NullNode.