最佳答案
假设我有输入:
{
"name": "John",
"email": "john@company.com"
}
{
"name": "Brad",
"email": "brad@company.com"
}
如何得到输出:
[
{
"name": "John",
"email": "john@company.com"
},
{
"name": "Brad",
"email": "brad@company.com"
}
]
我两种方法都试过了:
jq '[. | {name, email}]'
还有
jq '. | [{name, email}]'
它们都给了我输出
[
{
"name": "John",
"email": "john@company.com"
}
]
[
{
"name": "Brad",
"email": "brad@company.com"
}
]
我在文档中也没有看到数组输出的选项,感谢您的帮助