Filter expression with length function
Setup
Selector: $[?(@.length() == 4)]
[
[1,2,3,4,5],
[1,2,3,4],
[1,2,3]
]
Results
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(@.length() == 4)]': Invalid array index definition “?(@.length() == 4)]”
Clojure (json-path)
¹
[]
Cpp (jsoncons)
Not supported
Incorrect number of arguments at line 1 and column 14
Dart (json_path)
Not supported
end of input expected at 1:2
Elixir (ExJsonPath)
Not supported
syntax error before: '('
Elixir (jaxon)
[]
Elixir (warpath)
¹
Not supported
Parser error: Invalid token on line 1, syntax error before: <<"(">>
Erlang (ejsonpath)
Not supported
syntax error before: '('
Not supported
parsing error: $[?(@.length() == 4)] :1:14 - 1:15 unexpected ")" while scanning extensions
[
[
1,
2,
3,
4
]
]
Not supported
[]
[]
Not supported
invalid filter syntax at position 14, following ")"
Haskell (jsonpath)
Not supported
Invalid JSONPath: $[?(@.length() == 4)]
Error: 1:13:
|
1 | $[?(@.length() == 4)]
| ^
unexpected '('
expecting "!=", "&&", "<=", "==", ">=", "||", '!', ')', '.', '<', '>', '[', or white space
JavaScript (jsonpath)
[]
Java (com.github.jsurfer)
Not supported
org.antlr.v4.runtime.misc.ParseCancellationException
Java (com.jayway.jsonpath)
¹
³
[
[
1,
2,
3,
4
]
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[
[
1,
2,
3,
4
]
]
PHP (galbar-jsonpath)
Not supported
Invalid JSONPath error: 'Error in JSONPath near '()''
PHP (remorhaz-jsonpath)
[
[
1,
2,
3,
4
]
]
PHP (softcreatr-jsonpath)
[]
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:16 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}
ValueError("line 1:16 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}")
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[
[
1,
2,
3,
4,
5
],
[
1,
2,
3,
4
],
[
1,
2,
3
]
]
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
Not supported
path error:
$[?(@.length() == 4)]
^^^^^^^^^^^^^
Scala (jsonpath)
Not supported
JPError(end of input expected)
Swift (Sextant)
[
[
1,
2,
3,
4
]
]
dotNET (Json.NET)
Not supported
Array index expected.
dotNET (JsonCons.JsonPath)
Not supported
Invalid arity calling function 'length', expected 1, found 0
dotNET (JsonPath.Net)
Not supported
Pattern '(@.length(...' not recognized.
dotNET (Manatee.Json)
[
[
1,
2,
3,
4
]
]
JSON (Path_Reference_Implementation)
Not supported
--> 1:3
|
1 | $[?(@.length() == 4)]
| ^---
|
= expected unionChild, unionArrayIndex, or sliceStart
Proposal (A)
Not supported
x 1:13-1:13 ComparisonOperator
| $[?(@.length() == 4)]
| ^
| x 1:13-1:13 ScalarOperator
| | $[?(@.length() == 4)]
| | ^
| o 1:5-1:13 DocumentValue
| | $[?(@.length() == 4)]
| | ^^^^^^^^
| o 1:5-1:13 UnaryFilterExpression
| | $[?(@.length() == 4)]
| | ^^^^^^^^
| | x 1:13-1:13 ScalarOperator
| | | $[?(@.length() == 4)]
| | | ^
| | o 1:5-1:13 DocumentValue
| | | $[?(@.length() == 4)]
| | | ^^^^^^^^
| | o 1:5-1:13 FilterValue
| | | $[?(@.length() == 4)]
| | | ^^^^^^^^
| | |
|/ /
| |
|/
o 1:5-1:13 HigherPrecedenceFilterExpression
| $[?(@.length() == 4)]
| ^^^^^^^^
x 1:5-1:5 LogicalOr
| $[?(@.length() == 4)]
| ^
| x 1:13-1:13 ComparisonOperator
| | $[?(@.length() == 4)]
| | ^
| | x 1:13-1:13 ScalarOperator
| | | $[?(@.length() == 4)]
| | | ^
| | o 1:5-1:13 DocumentValue
| | | $[?(@.length() == 4)]
| | | ^^^^^^^^
| | o 1:5-1:13 UnaryFilterExpression
| | | $[?(@.length() == 4)]
| | | ^^^^^^^^
| | | x 1:13-1:13 ScalarOperator
| | | | $[?(@.length() == 4)]
| | | | ^
| | | o 1:5-1:13 DocumentValue
| | | | $[?(@.length() == 4)]
| | | | ^^^^^^^^
| | | o 1:5-1:13 FilterValue
| | | | $[?(@.length() == 4)]
| | | | ^^^^^^^^
| | | |
| |/ /
| | |
| |/
| o 1:5-1:13 HigherPrecedenceFilterExpression
| | $[?(@.length() == 4)]
| | ^^^^^^^^
| x 1:5-1:5 LogicalAnd
| | $[?(@.length() == 4)]
| | ^
| | x 1:13-1:13 ComparisonOperator
| | | $[?(@.length() == 4)]
| | | ^
| | | x 1:13-1:13 ScalarOperator
| | | | $[?(@.length() == 4)]
| | | | ^
| | | o 1:5-1:13 DocumentValue
| | | | $[?(@.length() == 4)]
| | | | ^^^^^^^^
| | | o 1:5-1:13 UnaryFilterExpression
| | | | $[?(@.length() == 4)]
| | | | ^^^^^^^^
| | | | x 1:13-1:13 ScalarOperator
| | | | | $[?(@.length() == 4)]
| | | | | ^
| | | | o 1:5-1:13 DocumentValue
| | | | | $[?(@.length() == 4)]
| | | | | ^^^^^^^^
| | | | o 1:5-1:13 FilterValue
| | | | | $[?(@.length() == 4)]
| | | | | ^^^^^^^^
| | | | |
| | |/ /
| | | |
| | |/
| | o 1:5-1:13 HigherPrecedenceFilterExpression
| | | $[?(@.length() == 4)]
| | | ^^^^^^^^
| | |
|/ /
| |
|/
o 1:5-1:13 FilterExpression
| $[?(@.length() == 4)]
| ^^^^^^^^
x 1:3-1:3 BracketElement
| $[?(@.length() == 4)]
| ^
x 1:3-1:3 BracketElements
| $[?(@.length() == 4)]
| ^
x 1:2-1:2 BracketChildren
| $[?(@.length() == 4)]
| ^
x 1:2-1:2 Operator
| $[?(@.length() == 4)]
| ^
o 1:1-1:2 Start
$[?(@.length() == 4)]
^
Errors
JavaScript (Goessner)
²
jsonPath: _v.length is not a function: _v.length() == 4
JavaScript (brunerd)
Invocation violation: length()
JavaScript (jsonpath-plus)
jsonPath: _$_v.length is not a function: @.length() == 4
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
Rust (jsonpath_plus)
Error Parsing JSON Path:
$[?(@.length() == 4)]
panic occurred
dotNET (JsonPathLib)
Object has no method 'length'
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.