Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

NiFi SplitJson, split json when expression condition is met and pass through when condition is not met

avatar
Contributor
Hi, I've been trying to get this to work, but am not sure how to complete it.

From a previous SplitJson I have a queue of Flowfiles in these two formats.
{
"s_id": 1000,
"parent": 0,
"items": {
       "2020": {
                "s_id": 2020,
                 "parent": 1000
        },
        "2021": {
                "s_id": 2021,
                "parent": 1000
        }
  }
}
and
{
"s_id": 1001,
"parent": 0
}

I would like to un-nest them further to the Flowfiles.
{
"s_id": 1000,
"parent": 0
}

{
"s_id": 2020,
"parent": 1000
}

{
"s_id": 2021,
"parent": 1000
}

{
"s_id": 1001,
"parent": 0
}

I've tried another SplitJson with a JsonPath expression of $.items[*], however this throws a failure for the json where "items" doesn't exist.
Can someone please guide me on the steps and processors I should be using to complete this task?
Is it possible with some type of conditional statement in the SplitJson JsonPath expression?

Thank you for your help!
1 REPLY 1

avatar
Contributor

Screenshot 2025-01-22 at 12.15.50 PM.png

To get the result I wanted this is the roundabout process I used. I would imagine there's a better way.