转换aws cli JSON输出
下面的aws cli命令返回以下命令转换aws cli JSON输出,json,amazon-web-services,jq,aws-cli,key-value,Json,Amazon Web Services,Jq,Aws Cli,Key Value,下面的aws cli命令返回以下命令 aws cloudformation describe-stacks --stack-name home-automation-service --region us-east-1 --query "Stacks[0].Outputs[*].{OutputKey:OutputKey,OutputValue:OutputValue}" --output json [ { "OutputKey"
aws cloudformation describe-stacks --stack-name home-automation-service --region us-east-1 --query "Stacks[0].Outputs[*].{OutputKey:OutputKey,OutputValue:OutputValue}" --output json
[
{
"OutputKey": "URLPath",
"OutputValue": "https://home-automation-service.jakeworld.com"
},
{
"OutputKey": "Port",
"OutputValue": "8080"
}
]
{
"URLPath": "https://home-automation-service.jakeworld.com",
"Port": "8080"
}
我想将json转换为类似以下内容
aws cloudformation describe-stacks --stack-name home-automation-service --region us-east-1 --query "Stacks[0].Outputs[*].{OutputKey:OutputKey,OutputValue:OutputValue}" --output json
[
{
"OutputKey": "URLPath",
"OutputValue": "https://home-automation-service.jakeworld.com"
},
{
"OutputKey": "Port",
"OutputValue": "8080"
}
]
{
"URLPath": "https://home-automation-service.jakeworld.com",
"Port": "8080"
}
是否可以使用aws cli中的--query
参数执行此操作?如果没有,请使用任何其他方法帮助?jq解决方案:
map( {(.OutputKey) : .OutputValue} ) | add
它总是这些输出,还是你在寻找一个通用的解决方案?我在寻找一个通用的解决方案