I want to use jsonfilter to read the required key from my json file.
My json file content is:
{
"rootbin": "/bin"
}
I want to read the 'rootbin' key value, so I used the following jsonfilter command:
cat test.json | jsonfilter -e @.rootbin
/bin
But I got an error related to the special characters when changing the key to 'root-bin' in the json file
cat test.json | jsonfilter -e @.root-bin
Syntax error: Invalid escape sequence
In expression @.root-bin
Near here ----------^
How to use jsonfilter with special characters?
I had same problem. Finally I found out that there is also another syntax: cat test.json | jsonfilter -e '@["root-bin"]
It works for me.
The help page of jsonfilter also refers to this page as allowed patterns https://goessner.net/articles/JsonPath/.