gpt4 book ai didi

arrays - 给定一个 json 数组,如何使用 jq 按键提取键值列表?

转载 作者:行者123 更新时间:2023-12-02 17:26:31 28 4
gpt4 key购买 nike

我有一个如下所示的 json 数组:

{
"StackSummaries": [
{
"CreationTime": "2016-06-01T22:22:49.890Z",
"StackName": "foo-control-eu-west-1",
"StackStatus": "UPDATE_COMPLETE",
"LastUpdatedTime": "2016-06-01T22:47:58.433Z"
},
{
"CreationTime": "2016-04-13T11:22:04.250Z",
"StackName": "foo-bar-testing",
"StackStatus": "UPDATE_COMPLETE",
"LastUpdatedTime": "2016-04-26T16:17:07.570Z"
},
{
"CreationTime": "2016-04-10T01:09:49.428Z",
"StackName": "foo-ldap-eu-west-1",
"StackStatus": "UPDATE_COMPLETE",
"LastUpdatedTime": "2016-04-17T13:44:04.758Z"
}
]
}

我希望创建如下所示的文本输出:

foo-control-eu-west-1
foo-bar-testing
foo-ldap-eu-west-1

jq能做到吗?具体来说,jq 命令行会选择数组中的每个 StackName 并每行输出每个键一个?

最佳答案

jq --raw-output '.StackSummaries[].StackName'

关于arrays - 给定一个 json 数组,如何使用 jq 按键提取键值列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38332971/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com