Filter expression with different grouped operators
Setup
Selector: $[?(@.a && (@.b || @.c))]
[
{
"a": true
},
{
"a": true,
"b": true
},
{
"a": true,
"b": true,
"c": true
},
{
"b": true,
"c": true
},
{
"a": true,
"c": true
},
{
"c": true
},
{
"b": true
}
]
Results
Consensus
[
{
"a": true,
"b": true
},
{
"a": true,
"b": true,
"c": true
},
{
"a": true,
"c": true
}
]
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(@.a && (@.b || @.c))]': Invalid array index definition “?(@.a && (@.b || @.c))]”
Clojure (json-path)
¹
[
{
"a": true,
"b": true,
"c": true
},
{
"a": true,
"c": true
}
]
Elixir (ExJsonPath)
Not supported
illegal characters "&"
Elixir (jaxon)
[]
Not supported
parsing error: $[?(@.a && (@.b || @.c))] - 1:11 unknown operator &&
Java (com.github.jsurfer)
Not supported
line 1:11 no viable alternative at input '('
org.antlr.v4.runtime.misc.ParseCancellationException
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
PHP (galbar-jsonpath)
Not supported
Invalid JSONPath error: 'Error in JSONPath near ')''
Python (jsonpath)
²
[
{
"a": true,
"b": true
},
{
"a": true,
"b": true,
"c": true
}
]
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:8 token recognition error at: '&'
ValueError("line 1:8 token recognition error at: '&'")
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_plus)
[
{
"a": true,
"b": true,
"c": true
}
]
Scala (jsonpath)
Not supported
JPError(end of input expected)
dotNET (Json.NET)
Not supported
Unexpected character while parsing path query: (
Errors
Erlang (ejsonpath)
Timeout
invalid char at 11: ` `
PHP (Goessner)
²
ArgumentCountError
PHP (softcreatr-jsonpath)
Error: 'Malformed filter query'
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
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.