Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Single equals in filter assigns value #210

Copy link
Copy link
@v-mwalk

Description

@v-mwalk
Issue body actions

Describe the bug

A filter erroneously using a single equals in a comparison filter modifies the filtering property in the target object.

Code sample or steps to reproduce

const originalJSON = {
        testing: [
          { test: "hello1", prop1: "bye1",  prop2: "day1" },
          { test: "hello2", prop1: "bye2",  prop2: "day2" },
          { test: "hello3", prop1: "bye3",  prop2: "day3" },
        ],
      };

const filteredJSON = JSONPath({path: '$.testing[?(@.test="hello2"].prop1',json: originalJSON, resultType" 'all'}); // Note single equals in filter

//
// originalJSON now contains;
//        testing: [
//          { test: "hello2", prop1: "bye1",  prop2: "day1" },
//          { test: "hello2", prop1: "bye2",  prop2: "day2" },
//          { test: "hello2", prop1: "bye3",  prop2: "day3" },
//        ],
//      };
//
//

Expected behavior

As the filter is errored, would expect an exception to be thrown, for handling by the caller.

Environment (IMPORTANT)

  • JSONPath-Plus version: 8.0.1

Desktop**

  • OS: Mac
  • Node 19.8.1

Additional context

Can also be repo'd at jsonpath.com evaluator

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.