One could assign a property [?(@.<property>=<value>)], it changes output · Issue #169 · JSONPath-Plus/JSONPath · GitHub
Skip to content

One could assign a property [?(@.<property>=<value>)], it changes output #169

Description

@vladvershinin

Describe the bug

If you put = instead of == or === in filter expression [?(@.<property>=<value>], it actually replaces in the result all values of that <property> with new <value>.

Code sample or steps to reproduce

{
  "books": [
    {
      "id": 1,
      "name": "HPMOR"
    },
    {
      "id": 2,
      "name": "TG"
    }
  ]
}

Json path

$..books[?(@.id=55)]

Result:

[
  {
    "id": 55,
    "name": "HPMOR"
  },
  {
    "id": 55,
    "name": "TG"
  }
]

Console error or logs

Tried this on https://jsonpath-plus.github.io/JSONPath/demo/ site, there were no errors in logs.

Expected behavior

I would prefer this handled as invalid syntax.

Expected result

hmm, it could be empty, idk

Environment (IMPORTANT)

Tried this on https://jsonpath-plus.github.io/JSONPath/demo/, sorry, can't find the version it uses.

Desktop**

  • OS: MacOS Monterey 12.2.1
  • Browser and version Mozilla 101.0

Additional context

Actually, this caught me in https://github.com/Kong/insomnia, but found this behavior in the library itself.
According to http://jsonpath.com/, original implementation has this issue too.

PS
Sorry, I am not a JS developer, cannot provide all details and didn't manage to track the root of the problem further.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions