I know how to use JSONPath in JavaScript to filter on the values:
var o = {
current_user_url: "https://api.github.com/user",
other_user_url: "https://api.github.com/user",
otherstuff: "stuff"
};
jsonPath(o, "$.[?(/https.*/.test(@))]") //returns ["https://api.github.com/user"]
But how to filter on the keys? I want to have all values returned where the key ends in *_url
. The following doesn't work since @
apparently only contains the value of the JSON objects.
jsonPath(o, "$.[?(/.*_url/.test(@))]")
If it's not possible with JSONPath or JSONQuery, is there another library that's easy to use and setup? I want the user to enter the query-expression, that's why I'd prefer to use a query language instead of just evaling plain JavaScript (like these guys).