问题
Following my previous post Jolt: 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 !
回答1:
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
} ]
来源:https://stackoverflow.com/questions/61416100/jolt-concat-array-values