JMESPath
These examples use jp.
Period in Key
{
"apiVersion": "v1",
"data": {
"tls.crt": "Zm9vCg==",
"tls.key": "YmFyCg=="
},
"kind": "Secret",
"type": "kubernetes.io/tls"
}
Quote it. Sometimes you can escape the period with a \ backslash.
echo $KubeSecret | jp 'data."tls.crt"'
#+RESULTS:
"Zm9vCg=="
Filters
startswith
{
"Exports": [
{
"ExportingStackId": "arn1",
"Name": "foo-cats",
"Value": "foo1"
},
{
"ExportingStackId": "arn2",
"Name": "foo-dogs",
"Value": "foo2"
},
{
"ExportingStackId": "arn3",
"Name": "bar-cats",
"Value": "bar1"
}
]
}
echo $Exports | jp "Exports[?starts_with(Name, 'foo')].Name"
#+RESULTS:
[ "foo-cats", "foo-dogs" ]