我认为这几乎是正确的我只是错过了一块,如果我选择Atlas
我想要显示Id
echo "${json}" |jq '.[] | select(.name=="atlas" | .id)'
JSON
[
{
"name": "atlas",
"id": 2314430,
"slug": "atlas",
"description": "",
"privacy": "closed",
"url": "https://api.github.com/teams/2314430",
"members_url": "https://api.github.com/teams/2314430/members{/member}",
"repositories_url": "https://api.github.com/teams/2314430/repos",
"permission": "pull"
},
{
"name": "HAL",
"id": 2318635,
"slug": "hal",
"description": "",
"privacy": "closed",
"url": "https://api.github.com/teams/2318635",
"members_url": "https://api.github.com/teams/2318635/members{/member}",
"repositories_url": "https://api.github.com/teams/2318635/repos",
"permission": "pull"
}
]
答案 0 :(得分:1)
我把酒吧放在了错误的一边
jq '.[] | select(.name=="atlas") | .id'