Skip to content
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

error loc.indexOf is not a function #181

Open
thboileau opened this issue Nov 8, 2022 · 1 comment
Open

error loc.indexOf is not a function #181

thboileau opened this issue Nov 8, 2022 · 1 comment

Comments

@thboileau
Copy link

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)

  • JSONPath-Plus version: 7.2.0

Desktop**

  • OS: Linux Ubuntu 20.04
  • Browser Chrome, version 107.0.5304.87
@TrurlMcByte
Copy link

TrurlMcByte commented Nov 24, 2022

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

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

No branches or pull requests

2 participants