JOLT :需要拆分数组并与其他细节结合

JOLT : Need to split array and combine with other details

我正在尝试 JSON 使用 JOLT 进行转换。 但是我被困在拆分 JSON 数组并附加其他详细信息的地方 如当前输出所示,我能够提取第 0 个值并附加详细信息,但如何提取下一个元素并附加 offerId。

输入JSON

{
  "count": 100,
  "data": [
    {
      "offerDetails": {
        "offerId": "1234"
      },
      "merchantDetails": {
        "merchantName": "merchantName",
        "merchantLocations": [
          {
            "merchantAddress": "merchantAddress1"
          },
          {
            "merchantAddress": "merchantAddress2"
          }
        ]
      }
    }
  ]
}

以下是我试过的规格

[
  {
    "operation": "shift",
    "spec": {
      "data": {
        "*": {
          "offerDetails": {
            "offerId": "offerId"
          },
          "merchantDetails": {
            "merchantLocations": {
              "0": {
                "merchantAddress": "merchant.name"
              }
            }
          }
        }
      }
    }
      }
]

当前输出

{
  "offerId" : "1234",
  "merchant" : {
    "name" : "merchantAddress1"
  }
}

期望的输出

[{
        "offerId": "1234",
        "merchant": {
            "name": "merchantAddress1"
        }
    },
    {
        "offerId": "1234",
        "merchant": {
            "name": "merchantAddress2"
        }
    }
]

这可以提供帮助,

遍历商户名称merchantLocations,从merchantLocations向后移动到offerId

[
  {
    "operation": "shift",
    "spec": {
      "data": {
        "*": {
          "merchantDetails": {
            "merchantLocations": {
              "*": {
                "@(3,offerDetails.offerId)": "[].offerId",
                "merchantAddress": "[&1].merchant.name"
              }
            }
          }
        }
      }
    }
  }
]