Filter expression with equals true
Setup
Selector: $[?(@.key==true)]
[
{
"some": "some value"
},
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Results
Other responses
Bash (JSONPath.sh)
[
true
]
C (json-glib)
Not supported
Unable to compile selector `$[?(@.key==true)]': Invalid array index definition “?(@.key==true)]”
Clojure (json-path)
¹
[
{
"some": "some value"
},
{
"key": null
}
]
Cpp (jsoncons)
[
{
"key": true
}
]
Dart (json_path)
[
{
"key": true
}
]
Elixir (ExJsonPath)
Not supported
syntax error before: <<"true">>
Elixir (jaxon)
[]
Elixir (warpath)
¹
[
{
"key": true
}
]
Erlang (ejsonpath)
Not supported
syntax error before: ')'
[
{
"key": true
}
]
[
{
"key": true
},
{
"key": 1
}
]
[
{
"key": true
}
]
[]
[
{
"key": true
}
]
[
{
"key": true
}
]
Haskell (jsonpath)
[
{
"key": true
}
]
JavaScript (Goessner)
²
[
{
"key": true
},
{
"key": 1
}
]
JavaScript (brunerd)
[
{
"key": true
}
]
JavaScript (jsonpath)
[
{
"key": true
},
{
"key": 1
}
]
JavaScript (jsonpath-plus)
[
{
"key": true
},
{
"key": 1
}
]
JavaScript (jsonpathly)
[
{
"key": true
}
]
Java (com.github.jsurfer)
[
{
"key": true
}
]
Java (com.jayway.jsonpath)
¹
³
[
{
"key": true
}
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[
{
"key": true
},
{
"key": 1
}
]
PHP (galbar-jsonpath)
[
{
"key": true
}
]
PHP (remorhaz-jsonpath)
[
{
"key": true
}
]
PHP (softcreatr-jsonpath)
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
}
]
Python (jsonpath)
²
Not found
jsonpath returned false, this might indicate an error
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}")
Python (python-jsonpath)
[
{
"key": true
},
{
"key": 1
}
]
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[
{
"key": true
}
]
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
[
{
"key": true
}
]
Rust (jsonpath_plus)
[
{
"key": true
}
]
Rust (serde_json_path)
[
{
"key": true
}
]
Scala (jsonpath)
[
{
"key": true
}
]
Swift (Sextant)
[
{
"key": true
},
{
"key": 1
}
]
dotNET (Json.NET)
[
{
"key": true
}
]
dotNET (JsonCons.JsonPath)
[
{
"key": true
}
]
dotNET (JsonPath.Net)
[
{
"key": true
}
]
dotNET (Manatee.Json)
[
{
"key": true
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Errors
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
dotNET (JsonPathLib)
Accessed JArray values with invalid key value: "valueOf". Int32 array index expected.
Footnotes
- ¹ This implementation returns a single value where only one match is possible (instead of an array of a single value).
- ² This implementation returns a specific not found value if no match exists.
- ³ This implementation returns a specific not found value if a query that would regularly return a single match results in no match.