jq将2个json文件中的对象数组中的字段合并到第3个json文件中 file1.json file2.json 所需输出:file3.json
对于这类问题,transpose think-zip通常可以用于生成紧凑的解决方案。在本案中:jq将2个json文件中的对象数组中的字段合并到第3个json文件中 file1.json file2.json 所需输出:file3.json,json,command-line,terminal,jq,Json,Command Line,Terminal,Jq,对于这类问题,transpose think-zip通常可以用于生成紧凑的解决方案。在本案中: jq -s 'transpose | map(add)' file1.json file2.json jq的转置也可以用于长度不相同的数组。仅供参考:在这种情况下,两个文件中的对象数量相同。 [ { "c": "c" }, { "c": "c" } ] [ { "a": "a", "b": "b", "c": "c" }, {
jq -s 'transpose | map(add)' file1.json file2.json
jq的转置也可以用于长度不相同的数组。仅供参考:在这种情况下,两个文件中的对象数量相同。
[
{
"c": "c"
},
{
"c": "c"
}
]
[
{
"a": "a",
"b": "b",
"c": "c"
},
{
"a": "a",
"b": "b",
"c": "c"
}
]
jq -s 'transpose | map(add)' file1.json file2.json