Filter expression with length function
Setup
Selector: $[?(@.length() == 4)]
[
[1,2,3,4,5],
[1,2,3,4],
[1,2,3]
]
Results
Consensus
Not supported
Other responses
Bash (JSONPath.sh)
[]
Clojure (json-path)
¹
[]
Elixir (jaxon)
[]
[
[
1,
2,
3,
4
]
]
[]
[]
JavaScript (jsonpath)
[]
Java (com.jayway.jsonpath)
¹
³
[
[
1,
2,
3,
4
]
]
Objective-C (SMJJSONPath)
¹
³
[
[
1,
2,
3,
4
]
]
PHP (remorhaz-jsonpath)
[
[
1,
2,
3,
4
]
]
PHP (softcreatr-jsonpath)
[]
Python (jsonpath)
²
Not found
jsonpath returned false, this might indicate an error
Ruby (jsonpath)
[
[
1,
2,
3,
4,
5
],
[
1,
2,
3,
4
],
[
1,
2,
3
]
]
Swift (Sextant)
[
[
1,
2,
3,
4
]
]
dotNET (Manatee.Json)
[
[
1,
2,
3,
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
JavaScript (jsonpathly)
no viable alternative at input '@.length()'
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)
Property 'length' of object is not a function
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.