【发布时间】:2021-10-31 23:26:47
【问题描述】:
我有如下 json 数据:
{
"Items": [
{
"id": {
"S": "c921e4eb-5958-424a-ae3a-b9cada0d9481"
},
"type": {
"S": "transaction.1612878877726"
}
},
{
"id": {
"S": "355057f0-4327-49c7-979f-5a27410d81ba"
},
"type": {
"S": "transaction.1612345630260"
}
},
{
"id": {
"S": "664dc02f-0ad8-484a-98a5-a403beea775b"
},
"type": {
"S": "transaction.1612164919232"
}
},
...
]
}
我想将 id 和 type 的值从 Items 数组中的每一项打印在一行中,例如
c921e4eb-5958-424a-ae3a-b9cada0d9481, transaction.1612878877726
355057f0-4327-49c7-979f-5a27410d81ba, transaction.1612345630260
...
我尝试了cat file | jq '.Items[].id.S, .Items[].type.S',但它在单独的行中打印id 和type。 jq怎么实现呢?
【问题讨论】: