I have the following json file
{
"result": {
"run": {
"runtime": "runc"
},
"software": {
"runc": "1.1.2",
"kata": "1.3.7"
}
}
}
I can extract the runtime info using this
# jq -r '.result.software .runc' input.json
1.1.2
However, if I try to extract the version number dynamically, it does not work (The runtime can change)
# runtime=$(jq -r '.result.run .runtime' input.json)
# jq --arg key "$runtime" '.result.software .[$key]'
jq: error: syntax error, unexpected '[', expecting FORMAT or QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
.result.software .[$key]
jq: 1 compile error