摇动:concat数组值 [英] Jolt: concat Array values

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

问题描述

在我之前的帖子之后 震动:在Nifi中拆分/合并数组值

Following my previous post Jolt: split/ concat array values in Nifi

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

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
  }
]

所需的输出:

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

最初的震动:

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

谢谢!

推荐答案

您可以最大程度地做到这一点,除此之外,使用某些链接规范可能会非常棘手.

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": "[].&"
      }
    }
  }
]

以上规格的输出:

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆