Java LongNode-class And Method Code Example
Here is an example of using the LongNode class from the com.fasterxml.jackson.databind package in the Jackson library for Java:
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.LongNode;
public class Main {
public static void main(String[] args) {
JsonNode longNode = new LongNode(1234567890123L);
System.out.println(longNode.asText()); // prints "1234567890123"
}
}
In this example, we first import the JsonNode and LongNode classes from the com.fasterxml.jackson.databind package.
Then, we create a new instance of LongNode with a value of 1234567890123L and assign it to longNode variable.
Finally, we print the text representation of longNode by calling the asText() method, which returns the string representation of the long value "1234567890123".
You can also use the longValue() method to get the long value of longNode variable instead of asText().
long value = longNode.longValue();
System.out.println(value); // prints 1234567890123