Filter expression with negation and equals array or equals true
Setup
Selector: $[?(!(@.d==["v1","v2"]) || (@.d == true))]
[
{"d": ["v1", "v2"] },
{"d": ["a", "b"] },
{"d" : true}
]
Results
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(!(@.d==["v1","v2"]) || (@.d == true))]': Invalid array index definition “?(!(@.d==["v1","v2"]) || (@.d == true))]”
Cpp (jsoncons)
[
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
Dart (json_path)
Not supported
Instance of 'ParserException': end of input expected (at 1:2)
Elixir (ExJsonPath)
Not supported
illegal characters "!("
Elixir (jaxon)
[]
Elixir (warpath)
¹
Not supported
Invalid syntax on line 1, {:illegal, '!('}
Not supported
parsing error: $[?(!(@.d==["v1","v2"]) || (@.d == true))] :1:5 - 1:6 unexpected "!" while scanning extensions
Not supported
invalid filter term at position 11, following "=="
Haskell (jsonpath)
Not supported
Invalid JSONPath: $[?(!(@.d==["v1","v2"]) || (@.d == true))]
Error: 1:12:
|
1 | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^^^^^
unexpected "["v1""
expecting "false", "null", "true", '!', '"', '$', ''', '@', digit, or white space
JavaScript (Goessner)
²
[
{
"d": [
"v1",
"v2"
]
},
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
JavaScript (brunerd)
[
{
"d": [
"v1",
"v2"
]
},
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
JavaScript (jsonpath)
[
{
"d": [
"v1",
"v2"
]
},
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
JavaScript (jsonpath-plus)
[
{
"d": [
"v1",
"v2"
]
},
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
JavaScript (jsonpathly)
[
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
Java (com.github.jsurfer)
Not supported
line 1:11 no viable alternative at input '@.d==['
org.antlr.v4.runtime.misc.ParseCancellationException
Java (com.jayway.jsonpath)
¹
³
[
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
PHP (galbar-jsonpath)
[
{
"d": [
"v1",
"v2"
]
},
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
PHP (remorhaz-jsonpath)
[
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
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:4 token recognition error at: '!('
ValueError("line 1:4 token recognition error at: '!('")
Python (python-jsonpath)
[
{
"d": [
"a",
"b"
]
}
]
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[]
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
Not supported
path error:
$[?(!(@.d==["v1","v2"]) || (@.d == true))]
^^^^
Rust (serde_json_path)
Not supported
at position 5, in long-hand segment, parser error
Scala (jsonpath)
Not supported
JPError(end of input expected)
Swift (Sextant)
[
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
dotNET (Json.NET)
Not supported
Unexpected character while parsing path query: !
dotNET (JsonCons.JsonPath)
[
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
dotNET (JsonPath.Net)
[
{
"d": [
"a",
"b"
]
}
]
dotNET (JsonPathLib)
[
{
"d": [
"v1",
"v2"
]
},
{
"d": [
"a",
"b"
]
},
{
"d": true
}
]
dotNET (Manatee.Json)
Not supported
Unrecognized JSON Path Expression element. Path up to error: '$'
Errors
Clojure (json-path)
¹
java.lang.Exception object must be an array.
Erlang (ejsonpath)
Timeout
unknown token at 7: ["v1","v2"])||(@.d==true) at 4
Exception: runtime error: comparing uncomparable type []interface {}
interface conversion: interface {} is nil, not string
wrong symbol '!' at 2
PHP (Goessner)
²
ArgumentCountError
PHP (softcreatr-jsonpath)
Error: 'Malformed filter query'
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
Rust (jsonpath_plus)
Error Parsing JSON Path:
$[?(!(@.d==["v1","v2"]) || (@.d == true))]
panic occurred
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.