PaesslerAG / jsonpath

BSD 3-Clause "New" or "Revised" License
172 stars 37 forks source link

GetWithPaths has wrong key for nested arrays #45

Closed whitlockjc closed 1 month ago

whitlockjc commented 1 month ago

I ran into an issue where deeply nested arrays could end up with the wrong computed key for GetWithPaths. Example below:

Example JSONPath

$.o1.a1[*].a2[?(@.p1 == "v1")]

Example Document

{
  "o1": {
    "a1": [
      {
        "a2": [
          {
            "p1": "v1"
          },
          {
            "p2": "v2"
          },
          {
            "p1": "v1"
          }
        ]
      },
      {},
      {
        "a2": [
          {
            "p1": "v1"
          },
          {
            "p2": "v2"
          },
          {
            "p1": "v1"
          }
        ]
      }
    ]
  }
}

Current Keys

Expected Keys