How to split a flow file json in nifi

21 Views Asked by At

Hi I want to split my flow file json arry into multiple json only if i have multiple json objects in my json array, if I have only one json object inside my json array i don't want to split it to multiple json arrays I just want to keep it as it is. Below is the example

Scenario 1

[ {
  "ID" : "123",
  "NAME" : "AAA",
  "CITY" : "BBB"
}, {
  "ID" : "456",
  "NAME" : "CCC",
  "CITY" : "DDD",
} ]

The above should be split as below(I am abel to do this using SplitJson processor and it is fine as well)

{
  "ID" : "123",
  "NAME" : "AAA",
  "CITY" : "BBB"
}

{
  "ID" : "456",
  "NAME" : "CCC",
  "CITY" : "DDD"
}

but where as in the scenario 2 i have only one json object ,so i dont want to split to multiple ,rather just want to keep it as it is

{
  "ID" : "123",
  "NAME" : "AAA",
  "CITY" : "BBB"
}

when i am using the same SplitJson processor then I could see the the split as like below which I don't want to do

{
  "ID" : "123"
}


{
  "NAME" : "AAA"
  
}

{
  
  "CITY" : "BBB"
}

Any help is much appreciated

0

There are 0 best solutions below