Skip to content

Support returning undefined for missing leaves in a path #158

Description

@jooleeanh

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions