我有2个文件:
f1.json
{
"a.b": {
"c": [ 1, 2 ]
},
"d": "other data"
}
f1.json
{
"a.b": {
"c": [ 3, 4 ]
}
}
[[f2.json中的嵌套数组的所有详细信息应合并到f1.json中,如下所示
f1.json:
{
"a.b": {
"c": [ 1, 2, 3, 4 ]
},
"d": "other data"
}
在f1.json中定位数组:访问f2.json中的数组(因为这将是一个静态文件,所以我们不必依赖于a.b的特定名称):jq -s'。[0] [“ a.b”]。c f1.json
jq。[]。c f2.json
j2.json
用作--argfile
中的参考,并在处理j1.json
时将数组内容加在一起jq --argfile sec f2.json '."a.b".c += $sec."a.b".c' f1.json