JSONPath-Plus / JSONPath

A fork of JSONPath from http://goessner.net/articles/JsonPath/
Other
958 stars 169 forks source link

error `loc.indexOf is not a function` #181

Open thboileau opened 1 year ago

thboileau commented 1 year ago

Describe the bug

I get this error with a specific expression: loc.indexOf is not a function

Code sample or steps to reproduce

Given this json payload:

{
  "stores": [
    { "name": "Store 1"},
    { "name": "Store 2" },
    { "name": "Store 3" },
    { "name": "Store 4"}
  ]
}

When I apply this path $.stores[1:4:2][(@.length-1)].name Then I get an error: loc.indexOf is not a function.

Please note that this expression ($.stores[1:4:2]) returns:

[
  { "name": "Store 2" },
  { "name": "Store 4" }
]

And this expression ($.stores[(@.length-1)].name) returns:

[
  "Store 4"
]

Expected behavior

There should be no error.

Expected result

"Store 4"

Environment (IMPORTANT)

Desktop**

TrurlMcByte commented 1 year ago

Getting the same error on deleting an element from an array inside callback. But splice solve it.