【发布时间】:2019-01-08 20:51:21
【问题描述】:
我正在尝试获取“参数”中具有“默认”键的元素列表:
{
"Parameters" : {
"Ecosystem": {
"Type": "String",
"Description": "Ecosystem to deploy the resources in to",
"MinLength": "1"
},
"InstanceTenancy": {
"Type": "String",
"Description": "EC2 Instance Tenancy",
"Default": "default",
"AllowedValues": [
"default", "dedicated"
]
},
"InstanceSecurityGroups": {
"Type": "List<AWS::EC2::SecurityGroup::Id>",
"Description": "EC2 Instance Security Groups",
"MinLength": "1"
},
"InstanceAmi": {
"Type": "AWS::EC2::Image::Id",
"Description": "AMI to deploy to the EC2 instances",
"Default": "ami-11223344"
}
}
}
我得到的最接近的是jq '.Parameters | map_values(has("Default"))'
{
"Ecosystem": false,
"InstanceTenancy": true,
"InstanceSecurityGroups": false,
"InstanceAmi": true
}
有没有办法只获取与此过滤器匹配的键列表?例如
"InstanceTenancy"
"InstanceAmi"
【问题讨论】:
标签: json select key extract jq