本文介绍了Jolt:连接数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照我之前的帖子Jolt:在 Nifi 中拆分/连接数组值

现在我希望将另一个值 (ts) 复制到每个拆分中.我的输入:

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

所需的输出:

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

最初的震动:

[{"操作": "移位",规格":{*":{"值*": "[].&"}}}]

谢谢!

解决方案

在最大情况下,您可以做到这一点,除此之外要实现上述目标将非常棘手,使用一些链式规范可能是可能的.

[{"操作": "移位",规格":{*":{"值*": "[].&","ts": "[].&"}}}]

以上规格的输出:

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

Following my previous postJolt: split/ concat array values in Nifi

Now I'd like another value (ts) to be replicated into each split.My input:

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

Desired output:

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

The initial Jolt:

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

Thanks !

解决方案

At the max you could do this, beyond this to achieve the above will be very tricky, using some chained spec it might be possible.

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

Output for above spec:

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

这篇关于Jolt:连接数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 05:03