【发布时间】:2020-06-10 07:25:17
【问题描述】:
问题:
我有 N 个对象数组,它们在对象中具有相同的标识键,我很想将它们与 jq 合并。
这是一个人为的例子,试图说明问题:
来自
[
{
"google.com": {
"http": {
"dest_url": "http://*.com"
}
}
},
{
"google.com": {
"https": {
"dest_url": "https://github.com"
}
}
},
{
"test.com": {
"https": {
"dest_url": "https://wikipedia.com"
}
}
}
]
收件人
{
"google.com": {
"http": {
"dest_url": "http://*.com"
},
"https": {
"dest_url": "https://github.com"
}
},
"test.com": {
"https": {
"dest_url": "https://wikipedia.com"
}
}
}
我尝试使用jq '. | add' file,但结果如下。
{
"google.com": {
"https": {
"dest_url": "https://github.com"
}
},
"test.com": {
"https": {
"dest_url": "https://wikipedia.com"
}
}
}
【问题讨论】: