转换 aws cli JSON 输出

Convert aws cli JSON output

下面的aws cli命令returns下面的

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"
    }    
]

我想将 json 转换为类似于以下内容

    {
        "URLPath": "https://home-automation-service.jakeworld.com",
        "Port": "8080"
    }

可以使用 aws cli 中的 --query 参数来完成吗?如果没有,感谢使用任何其他方式的帮助?

一个jq解决方案:

map( {(.OutputKey) : .OutputValue} ) | add