Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jq将2个json文件中的对象数组中的字段合并到第3个json文件中 file1.json file2.json 所需输出:file3.json_Json_Command Line_Terminal_Jq - Fatal编程技术网

jq将2个json文件中的对象数组中的字段合并到第3个json文件中 file1.json file2.json 所需输出:file3.json

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" }, {

对于这类问题,transpose think-zip通常可以用于生成紧凑的解决方案。在本案中:

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