I tried echo $json | jq '.result.hostid' but that returns error.
And what if I have to get the interface array belonging to a particular hostid?
Example: jq '.result[].hostid == 10084 | .result[].interface' obviously this doesn't work but I guess that explains my question? Basically return interface array for the hostid specified.
{
"jsonrpc": "2.0",
"result": [
{
"hostid": "10084",
"host": "host001",
"interfaces": [
{
"interfaceid": "1",
"ip": "127.0.0.1"
}
]
}
]
}
root@host001:~#echo $json | jq -r '.result.hostid'
jq: error (at <stdin>:1): Cannot index array with string "hostid"