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
FormatException: end of input expected at 1:2. Expression: $[?(!(@.d==["v1","v2"]) || (@.d == true))]
Elixir (ExJsonPath)
Not supported
illegal characters "!("
Elixir (jaxon)
[]
Elixir (warpath)
¹
Not supported
Invalid syntax on line 1, {:illegal, '!('}
Not supported
invalid syntax (position=1, reason=unrecognized input, near=[?(!(@.d==["v1","v2"]) || (@.d == true))])
Not supported
parsing error: $[?(!(@.d==["v1","v2"]) || (@.d == true))] :1:5 - 1:6 unexpected "!" while scanning extensions
Not supported
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
}
]
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: '!('")
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))]
^^^^
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 (Manatee.Json)
Not supported
Unrecognized JSON Path Expression element. Path up to error: '$'
JSON (Path_Reference_Implementation)
Not supported
--> 1:3
|
1 | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^---
|
= expected unionChild, unionArrayIndex, or sliceStart
Proposal (A)
Not supported
x 1:12-1:12 DocumentValue
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^
| x 1:12-1:12 IntegerPart
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| x 1:12-1:12 Number
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| x 1:12-1:12 SimpleValue
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| |
|/
x 1:12-1:12 FilterValue
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^
o 1:7-1:10 HigherPrecedenceFilterExpression
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^^^
x 1:7-1:7 LogicalOr
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^
| x 1:12-1:12 DocumentValue
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| | x 1:12-1:12 IntegerPart
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | x 1:12-1:12 Number
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | x 1:12-1:12 SimpleValue
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | |
| |/
| x 1:12-1:12 FilterValue
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| o 1:7-1:10 HigherPrecedenceFilterExpression
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^^^
| x 1:7-1:7 LogicalAnd
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| | x 1:12-1:12 DocumentValue
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | | x 1:12-1:12 IntegerPart
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | x 1:12-1:12 Number
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | x 1:12-1:12 SimpleValue
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | |
| | |/
| | x 1:12-1:12 FilterValue
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | o 1:7-1:10 HigherPrecedenceFilterExpression
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^^^
| | |
|/ /
| |
|/
o 1:7-1:10 FilterExpression
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^^^
x 1:6-1:6 UnaryFilterExpression
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^
x 1:5-1:5 UnaryFilterExpression
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^
x 1:5-1:5 HigherPrecedenceFilterExpression
| $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| ^
| x 1:12-1:12 DocumentValue
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| | x 1:12-1:12 IntegerPart
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | x 1:12-1:12 Number
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | x 1:12-1:12 SimpleValue
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | |
| |/
| x 1:12-1:12 FilterValue
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| o 1:7-1:10 HigherPrecedenceFilterExpression
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^^^
| x 1:7-1:7 LogicalOr
| | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | ^
| | x 1:12-1:12 DocumentValue
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | | x 1:12-1:12 IntegerPart
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | x 1:12-1:12 Number
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | x 1:12-1:12 SimpleValue
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | |
| | |/
| | x 1:12-1:12 FilterValue
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | o 1:7-1:10 HigherPrecedenceFilterExpression
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^^^
| | x 1:7-1:7 LogicalAnd
| | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | ^
| | | x 1:12-1:12 DocumentValue
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | | x 1:12-1:12 IntegerPart
| | | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | | ^
| | | | x 1:12-1:12 Number
| | | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | | ^
| | | | x 1:12-1:12 SimpleValue
| | | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | | ^
| | | | |
| | | |/
| | | x 1:12-1:12 FilterValue
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^
| | | o 1:7-1:10 HigherPrecedenceFilterExpression
| | | | $[?(!(@.d==["v1","v2"]) || (@.d == true))]
| | | | ^^^
| | | |
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
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
dotNET (JsonPathLib)
Object reference not set to an instance of an object.
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.