I want to convert the array values into the Individual JSON object using Jolt transform NiFi.
Input:
{
"headers": {
"query": "NA",
"param": "false"
},
"data": [
{
"SEQ_NUM": [
162,
162,
162,
162,
162,
162,
162,
162
]
},
{
"SEQ_NUM": [
162,
162,
162,
162,
162,
162,
162,
162
]
}
]
}
Jolt Spec:
[
{
"operation": "shift",
"spec": {
"data": {
"": {
"SEQ_NUM": {
"": {
"@": "[&1].SEQ_NUM"
}
}
}
}
}
}
]
CodePudding user response:
Your jolt spec is wrong. You should add *
to empty keys in your jolt. So you can use this spec:
[
{
"operation": "shift",
"spec": {
"data": {
"*": {
"SEQ_NUM": {
"*": {
"@": "[&1].SEQ_NUM"
}
}
}
}
}
}
]
If you want to prevent duplicate values in the output, You can use this spec:
[
{
"operation": "shift",
"spec": {
"data": {
"0": {
"SEQ_NUM": {
"*": {
"@": "[&1].SEQ_NUM"
}
}
}
}
}
}
]