Filter expression with length free 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)
[
[
1,
2,
3,
4
]
]
Dart (json_path)
[
[
1,
2,
3,
4
]
]
Elixir (ExJsonPath)
Not supported
syntax error before: <<"length">>
Elixir (jaxon)
[]
Elixir (warpath)
¹
Not supported
Parser error: Invalid token on line 1, forbidden function 'length', it's only allowed to call whitelist functions: [is_atom, is_binary, is_boolean, is_float, is_integer, is_list, is_map, is_nil, is_number, is_tuple]
Erlang (ejsonpath)
Not supported
syntax error before: '@'
[]
[]
Not supported
[]
[
[
1,
2,
3,
4
]
]
Not supported
invalid filter syntax at position 4, following "[?("
Haskell (jsonpath)
Not supported
Invalid JSONPath: $[?(length(@) == 4)]
Error: 1:5:
|
1 | $[?(length(@) == 4)]
| ^^^^^
unexpected "lengt"
expecting "false", "null", "true", '!', '"', '$', ''', '(', '@', digit, or white space
JavaScript (jsonpath)
[]
Java (com.github.jsurfer)
Not supported
line 1:4 no viable alternative at input 'length'
org.antlr.v4.runtime.misc.ParseCancellationException
Java (com.jayway.jsonpath)
¹
³
Not supported
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
com.jayway.jsonpath.InvalidPathException: Failed to parse filter: [?(length(@) == 4)], error on position: 3, char: l
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
Not supported
path node expected
PHP (galbar-jsonpath)
[]
PHP (remorhaz-jsonpath)
Not supported
Error: 'Failed to build AST from JSONPath query: $[?(length(@) == 4)]'
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 extraneous input 'length' expecting {'@', '$', 'not', 'true', 'false', 'null', '{', '[', '(', STRING, NUMBER}
ValueError("line 1:4 extraneous input 'length' expecting {'@', '$', 'not', '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)
Not supported
NOT_SUPPORTED
dotNET (Json.NET)
Not supported
Unexpected character while parsing path query: l
dotNET (JsonCons.JsonPath)
[
[
1,
2,
3,
4
]
]
dotNET (JsonPath.Net)
[
[
1,
2,
3,
4
]
]
dotNET (Manatee.Json)
Not supported
Unrecognized JSON Path Expression element. Path up to error: '$'
JSON (Path_Reference_Implementation)
Not supported
--> 1:3
|
1 | $[?(length(@) == 4)]
| ^---
|
= expected unionChild, unionArrayIndex, or sliceStart
Proposal (A)
Not supported
x 1:5-1:5 DocumentValue
| $[?(length(@) == 4)]
| ^
x 1:5-1:5 UnaryFilterExpression
| $[?(length(@) == 4)]
| ^
| x 1:5-1:5 DocumentValue
| | $[?(length(@) == 4)]
| | ^
| | x 1:5-1:5 IntegerPart
| | | $[?(length(@) == 4)]
| | | ^
| | x 1:5-1:5 Number
| | | $[?(length(@) == 4)]
| | | ^
| | x 1:5-1:5 SimpleValue
| | | $[?(length(@) == 4)]
| | | ^
| | |
| |/
| x 1:5-1:5 FilterValue
| | $[?(length(@) == 4)]
| | ^
| |
|/
x 1:5-1:5 HigherPrecedenceFilterExpression
| $[?(length(@) == 4)]
| ^
| x 1:5-1:5 DocumentValue
| | $[?(length(@) == 4)]
| | ^
| x 1:5-1:5 UnaryFilterExpression
| | $[?(length(@) == 4)]
| | ^
| | x 1:5-1:5 DocumentValue
| | | $[?(length(@) == 4)]
| | | ^
| | | x 1:5-1:5 IntegerPart
| | | | $[?(length(@) == 4)]
| | | | ^
| | | x 1:5-1:5 Number
| | | | $[?(length(@) == 4)]
| | | | ^
| | | x 1:5-1:5 SimpleValue
| | | | $[?(length(@) == 4)]
| | | | ^
| | | |
| | |/
| | x 1:5-1:5 FilterValue
| | | $[?(length(@) == 4)]
| | | ^
| | |
| |/
| x 1:5-1:5 HigherPrecedenceFilterExpression
| | $[?(length(@) == 4)]
| | ^
| x 1:5-1:5 LogicalOr
| | $[?(length(@) == 4)]
| | ^
| | x 1:5-1:5 DocumentValue
| | | $[?(length(@) == 4)]
| | | ^
| | x 1:5-1:5 UnaryFilterExpression
| | | $[?(length(@) == 4)]
| | | ^
| | | x 1:5-1:5 DocumentValue
| | | | $[?(length(@) == 4)]
| | | | ^
| | | | x 1:5-1:5 IntegerPart
| | | | | $[?(length(@) == 4)]
| | | | | ^
| | | | x 1:5-1:5 Number
| | | | | $[?(length(@) == 4)]
| | | | | ^
| | | | x 1:5-1:5 SimpleValue
| | | | | $[?(length(@) == 4)]
| | | | | ^
| | | | |
| | | |/
| | | x 1:5-1:5 FilterValue
| | | | $[?(length(@) == 4)]
| | | | ^
| | | |
| | |/
| | x 1:5-1:5 HigherPrecedenceFilterExpression
| | | $[?(length(@) == 4)]
| | | ^
| | x 1:5-1:5 LogicalAnd
| | | $[?(length(@) == 4)]
| | | ^
| | |
|/ /
| |
|/
x 1:5-1:5 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: length is not defined: length(_v) == 4
JavaScript (brunerd)
Invocation violation: (length(@)
JavaScript (jsonpath-plus)
jsonPath: length is not defined: length(@) == 4
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:
$[?(length(@) == 4)]
panic occurred
dotNET (JsonPathLib)
length is not defined
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.