NiFi Jolt 将字符串列表转换为 Map

NiFi Jolt transform list of string to Map

我想使用 Jolt 变换将字符串的 list/array 转换为 dict/map。游乐场在这里:https://jolt-demo.appspot.com/#inception

输入json是:

{
  "sites": {
    "urls": [
      "https://google.com/",
      "https://www.netflix.com/",
      "https://www.epicgames.com/"
    ]
  }
}

预期输出:

{
  "sites": [
    {
      "link": {
        "url": "https://google.com/"
      }
    },
    {
      "link": {
        "url": "https://www.netflix.com/"
      }
    },
    {
      "link": {
        "url": "https://www.epicgames.com/"
      }
    }
  ]
}

我尝试了其他转换,但没有找到 map/dictionary 的字符串列表示例。这里我们将输出的固定键设置为 link 和 url。关于解决方案的任何指示都会有所帮助。谢谢。

检查此规范

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "*": {
            "@": "sites[].link.url"
          }
        }
      }
    }
  }
]