JsonPath filter expressions? #269
-
Hi, just a quick one: does the jsonpath implementation support jsonpath filter expressions (e.g. $.results[?(@.desc == 'terra')].id) or do I have to use jq then? {
"links": [
{
"href": "https://cloud.mongodb.com/",
"rel": "self"
}
],
"results": [
{
"desc": "terra",
"id": "641dcxxxxxxx",
"links": [
{
"href": "https://cloud.mongodb.com/api/atlas/v2/",
"rel": "self"
}
],
"publicKey": "foofoofoo"
},
{
"desc": "svh_owner",
"id": "63f5c4dzzzzzzzzzzzz",
"links": [
{
"href": "https://clo",
"rel": "self"
}
],
"privateKey": "********-****-****-******",
"publicKey": "xwvzzzzzzzzz"
}
],
"totalCount": 3
} and then
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi, no. The implemented parser is - as written - a simple one where you only have access to the fields and arrays by index.
If you would like to use complex JsonPath expression you can use jsonpath-cli. Sadly it can not return the raw value, it will always return the value in JSON format (like {
'mistweaverco/kulala.nvim',
config = function()
require('kulala').setup({
contenttypes = {
["application/json"] = {
pathresolver = function(body, path)
local cmd = { "jpp", "-e", path}
local out = vim.system(cmd, { stdin = body, text = true }):wait().stdout
out = vim.fn.json_decode(out)
return out[1]
end,
},
},
})
end,
}, (Please use |
Beta Was this translation helpful? Give feedback.
-
@gorillamoe Maybe we can put this in the FAQ or the Configuration docs. |
Beta Was this translation helpful? Give feedback.
-
Somehow related: #270 (comment) |
Beta Was this translation helpful? Give feedback.
Hi,
no. The implemented parser is - as written - a simple one where you only have access to the fields and arrays by index.
JQ
can be used to parse but is another syntax not compatible with JsonPath.If you would like to use complex JsonPath expression you can use jsonpath-cli. Sadly it can not return the raw value, it will always return the value in JSON format (like
"content"
) and adds linefeeds (because it could be a list).But we can easily write a lua wrapper for it: