I try to retrieve 1
in :
$ cat object.json
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"annotations": {
"deployment.kubernetes.io/revision": "1"
}
}
}
$ xidel -e '($json).metadata.annotations["deployment.kubernetes.io/revision"]' -s object.json
{
"deployment.kubernetes.io/revision": "1"
}
Tried
'($json).metadata.annotations."deployment.kubernetes.io/revision"'
'($json).metadata.annotations.("deployment.kubernetes.io/revision")'
'($json).metadata.annotations.(deployment.kubernetes.io/revision)'
2
Answers
I've found:
Is it a correct way to do it?
I hardly ever use the dot-notation, because as far as I know in terms of capabilities it’s rather limited.
JSONiq notation:
Xpath-like notation with the XPath 3.1
map:get()
function:XPath 3.1 "?" lookup operator:
A combination of all notations: