Search code examples
jsonapache-nifijolt

joining particular arrays among many array in json Nifi


I have the following JSON:

{
  "list1":[1,2,3],
  "list2":[4,5,6],
  "list3":[7,8,9]
}

I just want to join list1 and list2.
Thus the desired output is :

{
  "Joined_list":[1,2,3,4,5,6],
  "list3":[7,8,9]
}

What will be the Jolt transform spec expression for this?


Solution

  • You just can use single step of shift transformation such as

    [
      {
        "operation": "shift",
        "spec": {
          "list1": {
            "*": {
              "@": "Final_List"
            }
          },
          "list2": {
            "*": {
              "@": "Final_List"
            }
          },
          "list3": "list3"
        }
      }
    ]