Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading array out of bound with JacksonJsonNodeJsonProvider #1028

Open
rigazilla opened this issue Feb 7, 2025 · 0 comments
Open

Reading array out of bound with JacksonJsonNodeJsonProvider #1028

rigazilla opened this issue Feb 7, 2025 · 0 comments

Comments

@rigazilla
Copy link

I'm accessing an array out-of-bound and I got a NullNode instead of an exception or a java null (if exceptions are suppressed).

This creates ambiguity as following:

           {
              "grades": [85, 90, 78, null, 44],
              "p1": null
            }

           JsonNode n1 = ctx.read("$.grades[3]");  // NullNode (valid index with null value)
           JsonNode n2 = ctx.read("$.grades[5]");  // NullNode (out of bounds)
           JsonNode n3 = ctx.read("$.p1");         // NullNode (existing property with null value)
           JsonNode n4 = ctx.read("$.p2");         // Exception or null (nonexistent property)

no way of distinguish an out-of-bound access from an existing null element

IMO array element access should behave like property access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant