Skip to content

ArrayNode.get() I'm accessing a null value or I'm out of bound? #4951

Answered by cowtowncoder
rigazilla asked this question in Q&A
Discussion options

You must be logged in to vote

Null elements are represented as non-null NullNodes, so JsonNode.isNull().

Or, if you don't want null checks, ArrayNode.path(int) never returns null but returns:

  1. NullNode if within Array value, JSON null value
  2. MissingNode if outside array (index out-of-bounds)

As to why null: design choice, to work similar to ObjectNode.get(String) for key that does not match any property; returns null.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rigazilla
Comment options

@cowtowncoder
Comment options

Answer selected by rigazilla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants