Jolt:concat数组值

问题描述 投票:0回答:1

继我以前的帖子之后Jolt: split/ concat array values in Nifi

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

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

谢谢!

apache-nifi jolt
1个回答
0
投票

最大程度地,您可以做到这一点,要实现上述目标将非常棘手,使用一些链接的规范是可能的。

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

以上规格的输出:

[ {
  "ts" : 1
}, {
  "value0" : 0
}, {
  "value1" : 1
}, {
  "value2" : 2
}, {
  "ts" : 2
}, {
  "value0" : 3
}, {
  "value1" : 4
}, {
  "value2" : 5
} ]
© www.soinside.com 2019 - 2024. All rights reserved.