【问题标题】:Jolt shift spec where output key is input value输出键为输入值的 Jolt shift 规范
【发布时间】:2020-11-26 06:04:42
【问题描述】:

简化输入

{
  "controllerServiceReferencingComponents": [
    {
      "revision": {
        "version": 5
      },
      "component": {
        "id": "9c050865-6d3a-3bb4-1ec5-b02fdfb103d1"
      }
    },
    {
      "revision": {
        "version": 1
      },
      "component": {
        "id": "a6ac00ee-0173-1000-24c9-70d812e16108"
      }
    }
  ]
}

想要的输出

{
  "referencingComponentRevisions": {
    "9c050865-6d3a-3bb4-1ec5-b02fdfb103d1": {
      "version": 5
    },
    "a6ac00ee-0173-1000-24c9-70d812e16108": {
      "version": 1
    }
  }
}

基本上我想在输入中使用controllerServiceReferencingComponents.component.id作为referencingComponentRevisions

我尝试过各种变化

[
  {
    "operation": "shift",
    "spec": {
      "controllerServiceReferencingComponents": {
        "*": {
          "component": {
            "id": "referencingComponentRevisions."
          },
          "revision": {
            "clientId": "referencingComponentRevisions.&.clientID"
          }
        }
      }
    }
  }
]

按照我的规范,但我最终会得到类似的输出

{
  "referencingComponentRevisions" : [ "9c050865-6d3a-3bb4-1ec5-b02fdfb103d1", "a6ac00ee-0173-1000-24c9-70d812e16108" ]
}

referencingComponentRevisions 的值最终是一个数组而不是一个对象

FWIW 我正在尝试在 NiFi JoltTransformJSON 处理器中执行此操作

【问题讨论】:

    标签: apache-nifi jolt


    【解决方案1】:

    这适用于简单的班次,

    [
      {
        "operation": "shift",
        "spec": {
          "controllerServiceReferencingComponents": {
            "*": {
              "component": {
                "@(1,revision.version)": "referencingComponentRevisions.@(1,id).version"
              }
            }
          }
        }
      }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-04
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多