将一个数组移动到另一个数组中定义的 json 个对象中 - JOLT 转换

Moving one array into json objects defined in another array - JOLT Transformation

我的输入定义为

{
    "lineId": "1",
    "Collection": {
        "services": [
            {
                "Code": "TB",
                "Type": [
                    "Data"
                ]
            },
            {
                "Code": "MAGTB",
                "Type": [
                    "Data"
                ]
            }
        ]
    },
    "promotions": [
        {
            "Id": "1"
        },
        {
            "Id": "2"
        }
    ]
}

我希望输出为

{
    "lineId": "1",
    "Collection": {
        "services": [
            {
                "Code": "TB",
                "Type": [
                    "Data"
                ],
                "promotions": [
                    {
                        "Id": "1"
                    },
                    {
                        "Id": "2"
                    }
                ]
            },
            {
                "Code": "TB2",
                "Type": [
                    "Data"
                ],
                "promotions": [
                    {
                        "Id": "1"
                    },
                    {
                        "Id": "2"
                    }
                ]
            }
        ]
    }
}

如有任何帮助,我们将不胜感激。

我是 JOLT 的新手。我无法从第一个数组导航到第二个数组。

我尝试的未完成转换:

[
  {
    "operation": "shift",
    "spec": {
      "Collection": {
        "services": {
     
          "*": "Collection.services[].&",
          "@(3,lineId)": "lineId",
          "@(3,promotions)":{
            "*":
          }
        }
      }
    }
  }
]

编辑:现在试过了

[
  {
    "operation": "shift",
    "spec": {
      "Collection": {
        "services": {
          "*": "Collection.services[]",
          //  "*": "&",
          "@(3,lineId)": "lineId",
          "@(3,promotions)": {
            "*": {
              "Id": "Id"
            }
          }
        }
      }
    }
  }
]

我只需要想办法将 Id 列表移动到服务数组中的对象中。

编辑2:

[
  {
    "operation": "shift",
    "spec": {
      "Collection": {
        "services": {
          "*": {
            "*": "Collection.services[&1].&",
            "@(3,lineId)": "Collection.services[&1].lineId",
            "@(3,promotions)": "Collection.services[&1].promotions"
          }
        }
      }
    }
  }
]

我认为这就是您要找的规格?

[
  {
    "operation": "shift",
    "spec": {
      "lineId": "lineId",
      "Collection": {
        "services": {
          "*": {
            "@(3,promotions)": "Collection.services[&1].promotions",
            "*": "Collection.services[&1].&"
          }
        }
      }
    }
  }
]