Skip to content

Support returning undefined for missing leaves in a path #158

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

Open
jooleeanh opened this issue Sep 6, 2021 · 1 comment
Open

Support returning undefined for missing leaves in a path #158

jooleeanh opened this issue Sep 6, 2021 · 1 comment
Labels

Comments

@jooleeanh
Copy link

Motivation

Have the return value include missing paths as undefined.

Current behavior

Missing paths are excluded.

Desired behavior

For this given JSON:

{
  "level1Array": [
    {
      "level2Index": 0
    },
    {
      "level2Index": 1,
      "level2Value": "2"
    }
  ]
}

$.level1Array[*].level2Value returns ["2"].
It would be useful to have an option so that it returns: [undefined, "2"].

Alternatives considered

I tried using the @undefined flag, but to no avail.
Another JSONPath library implemented this: joshbuddy/jsonpath#76

@Arul-
Copy link

Arul- commented Oct 20, 2023

I'm also looking for this feature

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

No branches or pull requests

2 participants