In Nifi, I have the following JSON:
{
"list1":[1,2,3],
"list2":[4,5]
}
I want the output to be:
{
"Final_List":[1,2,3,4,5]
}
How should I do this?
You can add a JoltTransformJSON processor with a shift type transformation such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"@": "Final_List"
}
}
}
}
]
Edit for special case :
If it was the case that those arrays have some common integer elements, then the above solution would yield repeating elements within the Final_List
, but the following make that result having unique elements for this case too :
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": "Final_List.&"
}
}
}
},
{
"operation": "shift",
"spec": {
"Final_List": {
"*": {
"$": "&2"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=toInteger(@(1,Final_List))"
}
}
]