Filter expression with equals with path and path

Setup

Selector: $[?(@.key1==@.key2)]

[
  {"key1": 10, "key2": 10},
  {"key1": 42, "key2": 50},
  {"key1": 10},
  {"key2": 10},
  {},
  {"key1": null, "key2": null},
  {"key1": null},
  {"key2": null},
  {"key1": 0, "key2": 0},
  {"key1": 0},
  {"key2": 0},
  {"key1": -1, "key2": -1},
  {"key1": "", "key2": ""},
  {"key1": false, "key2": false},
  {"key1": false},
  {"key2": false},
  {"key1": true, "key2": true},
  {"key1": [], "key2": []},
  {"key1": {}, "key2": {}},
  {"key1": {"a": 1, "b": 2}, "key2": {"b": 2, "a": 1}}
]

Results

Other responses

Bash (JSONPath.sh)

[]

C (json-glib)

Not supported

Unable to compile selector `$[?(@.key1==@.key2)]': Invalid array index definition “?(@.key1==@.key2)]”

Clojure (json-path) ¹

[
  {
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key2": 0
  },
  {
    "key2": false
  }
]

Cpp (jsoncons)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Dart (json_path)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

Elixir (ExJsonPath)

Not supported

syntax error before: '@'

Elixir (jaxon)

[]

Elixir (warpath) ¹

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Erlang (ejsonpath)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Golang (github.com-PaesslerAG-jsonpath) ¹

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Golang (github.com-bhmj-jsonslice) ¹ ³

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  }
]

Golang (github.com-oliveagle-jsonpath) ¹

[]

Golang (github.com-spyzhov-ajson)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Haskell (jsonpath)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

JavaScript (Goessner) ²

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

JavaScript (brunerd)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

JavaScript (jsonpath)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

JavaScript (jsonpath-plus)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

Java (com.github.jsurfer)

Not supported

line 1:12 no viable alternative at input '@.key1==@'
org.antlr.v4.runtime.misc.ParseCancellationException

Java (com.jayway.jsonpath) ¹ ³

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Kotlin (com.nfeld.jsonpathkt) ¹

Not supported

Unexpected char, char=?, index=2

Objective-C (SMJJSONPath) ¹ ³

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

PHP (galbar-jsonpath) ²

[
  {
    "key1": 10,
    "key2": 10
  },
  [],
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": false
  },
  {
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": [],
    "key2": []
  }
]

PHP (remorhaz-jsonpath)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

PHP (softcreatr-jsonpath)

[
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": 0
  },
  {
    "key1": true,
    "key2": true
  }
]

Python (jsonpath) ²

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Python (jsonpath-ng)

Not supported

JsonPathLexerError('Error on line 1, col 2: Unexpected character: ? ')

Python (jsonpath-rw)

Not supported

JsonPathLexerError('Error on line 1, col 2: Unexpected character: ? ')

Python (jsonpath2)

Not supported

line 1:11 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}
ValueError("line 1:11 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}")

Raku (JSON-Path)

Not supported

Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)

Ruby (jsonpath)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": 42,
    "key2": 50
  },
  {
    "key1": 10
  },
  {
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": 0
  },
  {
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": false
  },
  {
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Rust (jsonpath)

Not supported

parsing error

Rust (jsonpath_lib)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": 42,
    "key2": 50
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Rust (jsonpath_plus)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

Scala (jsonpath)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

Swift (Sextant)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

dotNET (Json.NET)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

dotNET (JsonCons.JsonPath)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": null
  },
  {
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

dotNET (JsonPath.Net)

[
  {
    "key1": 10,
    "key2": 10
  },
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  },
  {
    "key1": {
      "a": 1,
      "b": 2
    },
    "key2": {
      "a": 1,
      "b": 2
    }
  }
]

dotNET (JsonPathLib)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

dotNET (Manatee.Json)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  }
]

JSON (Path_Reference_Implementation)

Not supported

 --> 1:3
  |
1 | $[?(@.key1==@.key2)]
  |   ^---
  |
  = expected unionChild, unionArrayIndex, or sliceStart

Proposal (A)

[
  {
    "key1": 10,
    "key2": 10
  },
  {},
  {
    "key1": null,
    "key2": null
  },
  {
    "key1": 0,
    "key2": 0
  },
  {
    "key1": -1,
    "key2": -1
  },
  {
    "key1": "",
    "key2": ""
  },
  {
    "key1": false,
    "key2": false
  },
  {
    "key1": true,
    "key2": true
  },
  {
    "key1": [],
    "key2": []
  },
  {
    "key1": {},
    "key2": {}
  }
]

Errors

Golang (github.com-ohler55-ojg)

Exception: runtime error: comparing uncomparable type []interface {}

Golang (github.com-vmware-labs-yaml-jsonpath)

Exception: invalid type of value passed to compareNodeValues

PHP (Goessner) ²

ArgumentCountError

Perl (JSON-Path)

non-safe evaluation, died at main.pl line 11.

Footnotes