Skip to content

Quoted subscript can not work will with union/or subscripts. #159

Open
@nielinjie

Description

@nielinjie

Describe the bug

escape with quoted subscript can not work will with union/or subscripts.

Code sample or steps to reproduce

//PASS
test.only("some path with OR subscripts", () => {
  const obj = { functions: { foo: { io: "foo" }, bar: { out: "bar" } } };
  const jsonp = "$..[io,out]";
  const paths = jp.paths(obj, jsonp);
  expect(paths).toEqual([
    ["$", "functions", "foo", "io"],
    ["$", "functions", "bar", "out"],
  ]);
});
//PASS
test.only("some path with ESCAPE", () => {
  const obj = { functions: { foo: { "io.nest": "foo" }, bar: { out: "bar" } } };
  const jsonp = "$..['io.nest']";
  const paths = jp.paths(obj, jsonp);
  expect(paths).toEqual([
    ["$", "functions", "foo", "io.nest"],
  ]);
});
//FAILED
test.only("some path with ESCAPE and OR subscripts", () => {
  const obj = { functions: { foo: { 'io.nest': "foo" }, bar: { out: "bar" } } };
  const jsonp = "$..['io.nest',out]";
  const paths = jp.paths(obj, jsonp);
  expect(paths).toEqual([
    ["$", "functions", "foo", "io.nest"],
    ["$", "functions", "bar", "out"],
  ]);
});

Console error or logs

Expected behavior

All test case above should pass.

Expected result

Environment (IMPORTANT)

  • JSONPath-Plus version: 6.0.1

Desktop**

  • OS: Mac
  • Node Version: 15.12.0

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