Repository navigation
ArrayNode.get() I'm accessing a null value or I'm out of bound? #4951
|
How can I distinguish if I'm accessing a null element or the index is out of bound? What's the reason why ArrayNode.get() returns null on out of bound index? jackson-databind/src/main/java/tools/jackson/databind/node/ArrayNode.java Lines 221 to 226 in 961c128 |
Answered by
cowtowncoder
Feb 6, 2025
Replies: 1 comment 2 replies
|
Null elements are represented as non-null Or, if you don't want null checks,
As to why |
2 replies
Answer selected by
rigazilla
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Null elements are represented as non-null
NullNodes, soJsonNode.isNull().Or, if you don't want null checks,
ArrayNode.path(int)never returnsnullbut returns:NullNodeif within Array value, JSONnullvalueMissingNodeif outside array (index out-of-bounds)As to why
null: design choice, to work similar toObjectNode.get(String)for key that does not match any property; returnsnull.