Filter expression without value
Setup
Selector: $[?(@.key)]
[
{
"some": "some value"
},
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Results
Other responses
Bash (JSONPath.sh)
[]
C (json-glib)
Not supported
Unable to compile selector `$[?(@.key)]': Invalid array index definition “?(@.key)]”
Clojure (json-path)
¹
[
{
"key": true
},
{
"key": false
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Cpp (jsoncons)
[
{
"key": true
},
{
"key": "value"
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
}
]
Dart (json_path)
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Elixir (ExJsonPath)
Not supported
syntax error before: ')'
Elixir (jaxon)
[]
Elixir (warpath)
¹
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Erlang (ejsonpath)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
[
{
"key": true
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
}
]
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Not supported
[]
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
}
]
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Haskell (jsonpath)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
JavaScript (Goessner)
²
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
JavaScript (brunerd)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
JavaScript (jsonpath)
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
JavaScript (jsonpath-plus)
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Java (com.github.jsurfer)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Java (com.jayway.jsonpath)
¹
³
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Kotlin (com.nfeld.jsonpathkt)
¹
Not supported
Unexpected char, char=?, index=2
Objective-C (SMJJSONPath)
¹
³
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
PHP (galbar-jsonpath)
²
[
{
"key": true
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": []
},
{
"key": []
}
]
PHP (remorhaz-jsonpath)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
PHP (softcreatr-jsonpath)
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
}
]
Python (jsonpath)
²
[
{
"key": true
},
{
"key": "value"
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
}
]
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)
[]
Raku (JSON-Path)
Not supported
Evaluation of embedded Perl 6 code not allowed (construct with :allow-eval)
Ruby (jsonpath)
[
{
"key": true
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Rust (jsonpath)
Not supported
parsing error
Rust (jsonpath_lib)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Rust (jsonpath_plus)
[
{
"key": true
}
]
Scala (jsonpath)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Swift (Sextant)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
dotNET (Json.NET)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
dotNET (JsonCons.JsonPath)
[
{
"key": true
},
{
"key": "value"
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
}
]
dotNET (JsonPath.Net)
[
{
"key": true
},
{
"key": false
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
dotNET (Manatee.Json)
[
{
"key": true
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
JSON (Path_Reference_Implementation)
Not supported
--> 1:3
|
1 | $[?(@.key)]
| ^---
|
= expected unionChild, unionArrayIndex, or sliceStart
Proposal (A)
[
{
"key": true
},
{
"key": false
},
{
"key": null
},
{
"key": "value"
},
{
"key": ""
},
{
"key": 0
},
{
"key": 1
},
{
"key": -1
},
{
"key": 42
},
{
"key": {}
},
{
"key": []
}
]
Errors
PHP (Goessner)
²
ArgumentCountError
Perl (JSON-Path)
non-safe evaluation, died at main.pl line 11.
dotNET (JsonPathLib)
Unable to cast object of type 'Newtonsoft.Json.Linq.JArray' to type 'System.IConvertible'.
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.