Jolt: split/ concat array values in Nifi

假如想象 提交于 2021-01-29 13:47:41

问题


I'm struggling with transformation using JOLT in Nifi

My input

[
  {
    "value0": 0,
    "value1": 1,
    "value2": 2
  },
  {
    "value0": 3,
    "value1": 4,
    "value2": 5
  }
]

Desired Output:

[
 {"val" :0 },
 {"val" :1 },
 {"val" :2 },
 {"val" :3 },
 {"val" :4 },
 {"val" :5 },
 ]

I almost managed to get it to work. Here is my (wrong) Jolt Spec:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "value*": "[&1].val"
      }
    }
}

 ]

Here is my result:

[ {
  "val" : [ 0, 1, 2 ]
}, {
  "val" : [ 3, 4, 5 ]
} ]

Thanks!


回答1:


Try this,

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "value*": "[].val"
      }
    }
}]


来源:https://stackoverflow.com/questions/61387418/jolt-split-concat-array-values-in-nifi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!