小编bve*_*ely的帖子

如何使用 JQ 将两个 JSON 中的多个数组合并

我有两个 JSON 文件(file1.jsonfile2.json),其结构与下面定义的相同,并带有两个数组列表,如下所示。

第一个文件是(file1.json):

{
  "Lists1": [
   {
      "point": "a",
      "coordinates": [
        2289.48096,
        2093.48096
      ]
   }
  ],
  "Lists2": [
   {
      "point": "b",
      "coordinates": [
        2289.48096,
        2093.48096
      ]
   }
 ]
}
Run Code Online (Sandbox Code Playgroud)

第二个文件是(file2.json):

{
  "Lists1": [
   {
      "point": "c",
      "coordinates": [
        2289.48096,
        2093.48096
      ]
   }
  ],
  "Lists2": [
   {
      "point": "d",
      "coordinates": [
        2289.48096,
        2093.48096
      ]
   }
 ]
}
Run Code Online (Sandbox Code Playgroud)

所以我的预期输出将是:

{
  "Lists1": [
   {
      "point": "a",
      "coordinates": [
        2289.48096,
        2093.48096
      ]
   },
   {
      "point": …
Run Code Online (Sandbox Code Playgroud)

linux json jq

4
推荐指数
1
解决办法
7258
查看次数

标签 统计

jq ×1

json ×1

linux ×1