我正在努力理解如何正确使用jq来解析.json输出
我有这个文件:
{
"collections":[
{
"id":"XXXXX-XXXX-XXXXX-XXXXX-XXXXXXX",
"name":"Collection One",
"owner":"me",
"uid":"10020232-XXXXX-XXXX-XXXXX-XXXXX-XXXXXXX",
"isPublic":false
},
{
"id":"YYYYY-YYYY-YYYYY-YYYYY-YYYYYYY",
"name":"Collection Two",
"owner":"me",
"uid":"10020232-YYYYY-YYYY-YYYYY-YYYYY-YYYYYYY",
"isPublic":false
},
{
"id":"ZZZZZ-ZZZZ-ZZZZZ-ZZZZZ-ZZZZZZZ",
"name":"Collection Three",
"owner":"me",
"uid":"ZZZZZ-ZZZZ-ZZZZZ-ZZZZZ-ZZZZZZZ",
"isPublic":false
},
}
我能以某种方式得到";uid";对于具有";name":"Collecion Three">
任何类似SELECT uid FROM集合的内容,其中"name"="收藏三";
提前感谢大家
jq
有一个select
过滤器:
.collections[] | select(.name == "Collection Three").uid