NIFI | nifi Extract content from json array into separate attribute
Hi,
I have a json in the below format
[
{
"order_id": 1,
"category": 123
},
{
"order_id": 2,
"category": 123
},
{
"order_id": 3,
"category": 456
},
{
"order_id": 4,
"category": 321
}
]
I want to create flowfiles seperatly for all the categories,
flowfile1 - orders of category 123:
[
{
"order_id": 1,
"category": 123
},
{
"order_id": 2,
"category": 123
}
]
flowfile2 - orders of category 456
[
{
"order_id": 3,
"category": 456
}
]
flowfile3 - orders of category 321:
[
{
"order_id": 4,
"category": 321
}
]
I don't want to use splitjson, because this will be applied on millions of records. I don't want millions of flowfiles.
I tried EvaluateJsonPath and RouteOnAttribute
all_category : $.[*].category - this creates on attribute with all category values
RouteOnAttribute
category_123 : ${all_category:contains(123)}
category_321 : ${all_category:contains(321)}
category_456 : ${all_category:contains(456)}
But all the 3 flowfiles routed has all the order details.
Please guide me here, I am new to NIFI

