Filter expression with length property
Setup
Selector: $[?(@.length == 4)]
[
[1,2,3,4,5],
[1,2,3,4],
[1,2,3]
]
Results
Consensus
[]
Other responses
C (json-glib)
Not supported
Unable to compile selector `$[?(@.length == 4)]': Invalid array index definition “?(@.length == 4)]”
Clojure (json-path)
¹
[
[
1,
2,
3,
4,
5
],
[
1,
2,
3,
4
],
[
1,
2,
3
]
]
Cpp (jsoncons)
[
[
1,
2,
3,
4
]
]
[
[
1,
2,
3,
4
]
]
JavaScript (Goessner)
²
[
[
1,
2,
3,
4
]
]
JavaScript (brunerd)
[
[
1,
2,
3,
4
]
]
JavaScript (jsonpath)
[
[
1,
2,
3,
4
]
]
JavaScript (jsonpath-plus)
[
[
1,
2,
3,
4
]
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
PHP (galbar-jsonpath)
[
[
1,
2,
3,
4
]
]
Python (jsonpath)
²
[
[
1,
2,
3,
4
]
]
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:14 extraneous input '=' expecting {'@', '$', 'true', 'false', 'null', '{', '[', STRING, NUMBER}
ValueError("line 1:14 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
]
]
dotNET (JsonCons.JsonPath)
[
[
1,
2,
3,
4
]
]
dotNET (JsonPathLib)
[
[
1,
2,
3,
4
]
]
dotNET (Manatee.Json)
[
[
1,
2,
3,
4
]
]
Errors
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
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.