Filter expression with in current object
Setup
Selector: $[?(2 in @.d)]
[{"d": [1, 2, 3]}, {"d": [2]}, {"d": [1]}, {"d": [3, 4]}, {"d": [4, 2]}]
Results
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(2 in @.d)]': Invalid array index definition “?(2 in @.d)]”
Clojure (json-path)
¹
[]
Cpp (jsoncons)
Not supported
Expected dot or left bracket separator at line 1 and column 7
Dart (json_path)
Not supported
Instance of 'ParserException': end of input expected (at 1:2)
Elixir (ExJsonPath)
Not supported
syntax error before: 2
Elixir (jaxon)
[]
Elixir (warpath)
¹
Not supported
Parser error: Invalid token on line 1, syntax error before: <<"@">>
Erlang (ejsonpath)
Not supported
syntax error before: <<"in">>
Not supported
parsing error: $[?(2 in @.d)] :1:7 - 1:9 unexpected Ident while scanning parentheses expected ")"
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
[]
Not supported
jsonpath: invalid comparison operator at position 7
Not supported
invalid filter expression at position 6, following "2 "
Haskell (jsonpath)
Not supported
Invalid JSONPath: $[?(2 in @.d)]
Error: 1:7:
|
1 | $[?(2 in @.d)]
| ^^
unexpected "in"
expecting "!=", "<=", "==", ">=", '!', '<', '>', or white space
JavaScript (Goessner)
²
[
{
"d": [
1,
2,
3
]
}
]
JavaScript (brunerd)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
1
]
},
{
"d": [
3,
4
]
},
{
"d": [
4,
2
]
}
]
JavaScript (jsonpath)
[]
JavaScript (jsonpathly)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
Java (com.github.jsurfer)
Not supported
line 1:4 no viable alternative at input '2'
org.antlr.v4.runtime.misc.ParseCancellationException
Java (com.github.xmljacquard.ajp)
Not supported
Error at char 18 in expression in xsl:sequence/@select on line 20 column 67 of ajp-runner.xslt:
<failed xmlns:ixml="http://invisiblexml.org/NS"
ixml:state="failed"><line>1</line><column>7</column><pos>7</pos><unexpected>i</unexpected><permitted>#9, #A, #D, ' ', '!', '<', '=', '>'</permitted><could-be-next><in rule="comparison-op"><tokens>'!', '<', '=', '>'</tokens></in><in rule="B"><tokens>#9, #A, #D, ' '</tokens></in></could-be-next><unfinished><open rule="comparison-expr" start="5" end="6"><input>2 </input></open><open rule="int" start="5" end="5"><input>2</input></open><open rule="number" start="5" end="5"><input>2</input></open><open rule="paren-expr" start="4" end="4"><input>(</input></open><open rule="filter-selector" start="3" end="3"><input>?</input></open><open rule="bracketed-selection" start="2" end="2"><input>[</input></open><open rule="jsonpath-query" start="1" end="1"><input>$</input></open></unfinished></failed>
During lazy evaluation of tailCallLoop(ajp:getProcessor(...)) on line 20 of jar:file:./implementations/Java_com.github.xmljacquard.ajp/build/deps/org/xmljacquard/ajp/0.0.7/ajp-0.0.7.jar!/xslt/ajp-runner.xslt
In function ajpr:getProcessor on line 17 column 106 of ajp-runner.xslt:
net.sf.saxon.s9api.SaxonApiException: <failed xmlns:ixml="http://invisiblexml.org/NS" ixml:state="failed"><line>1</line><column>7</column><pos>7</pos><unexpected>i</unexpected><permitted>#9, #A, #D, ' ', '!', '<', '=', '>'</permitted><could-be-next><in rule="comparison-op"><tokens>'!', '<', '=', '>'</tokens></in><in rule="B"><tokens>#9, #A, #D, ' '</tokens></in></could-be-next><unfinished><open rule="comparison-expr" start="5" end="6"><input>2 </input></open><open rule="int" start="5" end="5"><input>2</input></open><open rule="number" start="5" end="5"><input>2</input></open><open rule="paren-expr" start="4" end="4"><input>(</input></open><open rule="filter-selector" start="3" end="3"><input>?</input></open><open rule="bracketed-selection" start="2" end="2"><input>[</input></open><open rule="jsonpath-query" start="1" end="1"><input>$</input></open></unfinished></failed>
Java (com.jayway.jsonpath)
¹
³
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
PHP (galbar-jsonpath)
[]
PHP (remorhaz-jsonpath)
Not supported
Error: 'Failed to build AST from JSONPath query: $[?(2 in @.d)]'
PHP (softcreatr-jsonpath)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
1
]
},
{
"d": [
3,
4
]
},
{
"d": [
4,
2
]
}
]
Python (jsonpath)
²
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
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:6 mismatched input 'in' expecting ')'
ValueError("line 1:6 mismatched input 'in' expecting ')'")
Python (python-jsonpath)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
Raku (JSON-Path)
Not supported
Evaluation of embedded Raku code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
1
]
},
{
"d": [
3,
4
]
},
{
"d": [
4,
2
]
}
]
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
Not supported
path error:
$[?(2 in @.d)]
^^^^^^
Rust (serde_json_path)
Not supported
at position 4, in long-hand segment, parser error
Scala (jsonpath)
Not supported
JPError(end of input expected)
Swift (Sextant)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
dotNET (Json.NET)
Not supported
Could not read query operator.
dotNET (JsonCons.JsonPath)
Not supported
Syntax error
dotNET (JsonPath.Net)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
4,
2
]
}
]
dotNET (JsonPathLib)
[
{
"d": [
1,
2,
3
]
},
{
"d": [
2
]
},
{
"d": [
1
]
},
{
"d": [
3,
4
]
},
{
"d": [
4,
2
]
}
]
dotNET (Manatee.Json)
Not supported
Unrecognized JSON Path Expression element. Path up to error: '$'
Errors
not enough arguments
wrong request: wrong request: ?(2 in @.d)
JavaScript (json-p3)
unexpected filter selector token 'i' ('2 in @.d)':8)
JavaScript (jsonpath-plus)
jsonPath: in is not defined: 2 in @.d
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
Rust (jsonpath_plus)
Error Parsing JSON Path:
$[?(2 in @.d)]
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.