I want to use Apache NiFi's built-in processor 'SplitJson' to split a JSON array. I've done it before and it works perfectly but now I can't seem to find the right json path expression to split my json. The JSON I get is simply from github:
https://api.github.com/events
I want to get each event in a seperate flowfile. In the description of the processor it states:
A JsonPath expression that indicates the array element to split into JSON/scalar fragments.
So because it's the root array I want to split I try using $ or @ but this won't work. Equally *
or [*]
or other things that I think are wrong like $.[*]
etc. don't work. In some cases it just doesn't split anything, other times it gives an error simply saying it can't find the array.
Thanks in advance for any suggestions or help!
I believe all you need to do is have a JSON Path of $.*
. This should split the array into a FlowFile per element.
To demonstrate, I created and uploaded a template here[1]. It takes in the JSON using GetHTTP, splits it using SplitJSON and ends at a LogAttribute (for testing purposes). Note that I believe GitHub requires you to use https (initial testing failed using http) so you will need to configure an SSL context with a keystore.
[1] https://gist.github.com/JPercivall/e1b5ba00a45c464fd764
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With