Filter expression with equals

Setup

Selector: $[?(@.key==42)]

[
    {"key": 0},
    {"key": 42},
    {"key": -1},
    {"key": 1},
    {"key": 41},
    {"key": 43},
    {"key": 42.0001},
    {"key": 41.9999},
    {"key": 100},
    {"key": "some"},
    {"key": "42"},
    {"key": null},
    {"key": 420},
    {"key": ""},
    {"key": {}},
    {"key": []},
    {"key": [42]},
    {"key": {"key": 42}},
    {"key": {"some": 42}},
    {"some": "value"}
]

Results

Other responses

Bash (JSONPath.sh)

[
  42,
  "42"
]

C (json-glib)

Not supported

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

Clojure (json-path) ¹

[
  {
    "key": null
  },
  {
    "some": "value"
  }
]

Cpp (jsoncons)

[
  {
    "key": 42
  }
]

Dart (json_path)

[
  {
    "key": 42
  }
]

Elixir (ExJsonPath)

[
  {
    "key": 42
  }
]

Elixir (jaxon)

[]

Elixir (warpath) ¹

[
  {
    "key": 42
  }
]

Erlang (ejsonpath)

[
  {
    "key": 42
  }
]

Golang (github.com-AsaiYusuke-jsonpath) ²

[
  {
    "key": 42
  }
]

Golang (github.com-PaesslerAG-jsonpath) ¹

[
  {
    "key": 42
  }
]

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

[
  {
    "key": 42
  },
  {
    "key": "42"
  }
]

Golang (github.com-ohler55-ojg)

[
  {
    "key": 42
  }
]

Golang (github.com-oliveagle-jsonpath) ¹

[]

Golang (github.com-spyzhov-ajson)

[
  {
    "key": 42
  }
]

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

[
  {
    "key": 42
  }
]

Haskell (jsonpath)

[
  {
    "key": 42
  }
]

JavaScript (Goessner) ²

[
  {
    "key": 42
  },
  {
    "key": "42"
  },
  {
    "key": [
      42
    ]
  }
]

JavaScript (brunerd)

[
  {
    "key": 42
  }
]

JavaScript (jsonpath)

[
  {
    "key": 42
  },
  {
    "key": "42"
  },
  {
    "key": [
      42
    ]
  }
]

JavaScript (jsonpath-plus)

[
  {
    "key": 42
  },
  {
    "key": "42"
  },
  {
    "key": [
      42
    ]
  }
]

Java (com.jayway.jsonpath) ¹ ³

[
  {
    "key": 42
  },
  {
    "key": "42"
  }
]

Kotlin (com.nfeld.jsonpathkt) ¹

Not supported

Unexpected char, char=?, index=2

Objective-C (SMJJSONPath) ¹ ³

[
  {
    "key": 42
  },
  {
    "key": "42"
  }
]

PHP (galbar-jsonpath) ²

[
  {
    "key": 42
  }
]

PHP (remorhaz-jsonpath)

[
  {
    "key": 42
  }
]

PHP (softcreatr-jsonpath)

[
  {
    "key": 42
  },
  {
    "key": "42"
  }
]

Python (jsonpath) ²

[
  {
    "key": 42
  }
]

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:10 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}
ValueError("line 1:10 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)

[
  {
    "key": 42
  },
  {
    "key": "42"
  }
]

Rust (jsonpath)

[]

Rust (jsonpath_lib)

[
  {
    "key": 42
  }
]

Rust (jsonpath_plus)

[
  {
    "key": 42
  }
]

Scala (jsonpath)

[
  {
    "key": 42
  }
]

Swift (Sextant)

[
  {
    "key": 42
  },
  {
    "key": "42"
  }
]

dotNET (Json.NET)

[
  {
    "key": 42
  }
]

dotNET (JsonCons.JsonPath)

[
  {
    "key": 42
  }
]

dotNET (JsonPath.Net)

[
  {
    "key": 42
  }
]

dotNET (JsonPathLib)

[
  {
    "key": 42
  },
  {
    "key": "42"
  }
]

dotNET (Manatee.Json)

[
  {
    "key": 42
  }
]

JSON (Path_Reference_Implementation)

Not supported

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

Proposal (A)

[
  {
    "key": 42
  }
]

Errors

Java (com.github.jsurfer)

java.lang.NumberFormatException: Character " is neither a decimal digit number, decimal point, nor "e" notation exponential mark.

PHP (Goessner) ²

ArgumentCountError

Perl (JSON-Path)

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

Footnotes