0
votes

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
It looks like this case is too complex for Jolt... - dams

1 Answers

0
votes

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