Skip to content

Getting the last element after filtering doesn't seem to work #1012

Open
@con-f-use

Description

@con-f-use

Given this json:

{
  "changes": [
    {
      "toHash": "0000000000000000000000000000000000000000"
    },
    {
      "toHash": "bb7550763f970f71a9053bf238ec46815c33c4e3"
    },
    {
      "toHash": "198fb09bb2aab83bf238ec53e01a48ac83c553d1",
      "WANTED": "WANTED"
    },
    {
      "toHash": "0000000000000000000000000000000000000000"
    }
  ]
}

I would expect this JSONPath expression:

$.changes.[?(@.toHash!="0000000000000000000000000000000000000000")][-1:]

To give the last element, where the toHash is not all zeros, i.e. element:

    {
      "toHash": "198fb09bb2aab83bf238ec53e01a48ac83c553d",
      "WANTED": "WANTED"
    }

However, I get an empy list []. Ist this a bug, or am I misunderstanding something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions