使用 Jolt 将顶级元素复制到数组的每个元素中

Copy a top level element into each element of an array using Jolt

我正在努力将顶级字段下推到其中数组的每个元素中。

我想将 'sourceEntity' 推入 'supportedCountries' 数组和 'supportedCurrencies' 数组的每个元素

输入JSON:

{
  "description": "SUPPORTED_COUNTRY_CURRENCY",
  "id": "20190902025202944",
  "type": "devuae-SUPPORTED_COUNTRY_CURRENCY",
  "sourceEntity": "EBI",
  "sourceChannel": "COR",
  "timestamp": "1567421549887",
  "supportedCountries": [
    {
      "code": "IN",
      "name": "India",
      "supportedCurrencies": [
        {
          "code": "JOD",
          "name": "JORDANIAN DINAR",
          "isLocal": true
        }
      ]
    }
  ]
}

预期输出:

{
  "description": "SUPPORTED_COUNTRY_CURRENCY",
  "id": "20190902025202944",
  "type": "devuae-SUPPORTED_COUNTRY_CURRENCY",
  "sourceEntity": "EBI",
  "sourceChannel": "COR",
  "timestamp": "1567421549887",
  "supportedCountries": [
    {
      "EntityID": "EBI",
      "code": "IN",
      "name": "India",
      "supportedCurrencies": [
        {
          "UnitID": "EBI",
          "code": "JOD",
          "name": "JORDANIAN DINAR",
          "isLocal": true
        }
      ]
    }
  ]
}

帮我解决这个问题

这可能会有所帮助,

[
  {
    "operation": "shift",
    "spec": {
      "description": "description",
      "id": "id",
      "type": "type",
      "sourceEntity": "sourceEntity",
      "sourceChannel": "sourceChannel",
      "timestamp": "timestamp",
      "supportedCountries": {
        "*": {
          //Shifting sourceEntity from the level 1
          "@(2,sourceEntity)": "supportedCountries[&1].EntityID",
          "code": "supportedCountries[&1].code",
          "name": "supportedCountries[&1].name",
          "supportedCurrencies": {
            "*": {
              //Shifting sourceEntity from the level 1
              "@(4,sourceEntity)": "supportedCountries[&1].supportedCurrencies[&1].UnitID",
              "code": "supportedCountries[&1].supportedCurrencies[&1].code",
              "name": "supportedCountries[&1].supportedCurrencies[&1].name",
              "isLocal": "supportedCountries[&1].supportedCurrencies[&1].isLocal"
            }
          }
        }
      }
    }
  }
]