Jens,

Try ForkRecord [1] with "Mode" set to "Extract" and "Include Parent
Fields" set to "true", I think that does what you're looking to do.

Regards,
Matt

[1] 
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.12.1/org.apache.nifi.processors.standard.ForkRecord/index.html

On Fri, Sep 25, 2020 at 1:48 AM Jens M. Kofoed <jmkofoed....@gmail.com> wrote:
>
> Hi
>
> I have a JSON document with an array which I would like to split and flatten.
> In my example below key4 is an array containing 2 documents. I need to split 
> the record based on each document in the key4 array, so I end up with 
> multiple records. Where each new record has a copy of all keys except key4 
> which should be flatten into each own document.
> {
> key1:value1,
> key2:value2,
> key3: {
>   key3a:value3a,
>   key3b:value3b
> }
> key4: [
>    {
>       key4a1:value4a1,
>       key4a2:value4a2
>   },
>   {
>       key4b1:value4b1,
>       key4b2:value4b2
>   }
> ]
> }
>
> Should be like this:
> Record 1
> {
> key1:value1,
> key2:value2,
> key3: {
>   key3a:value3a,
>   key3b:value3b
> }
> key4:{
>    key4a1:value4a1,
>    key4a2:value4a2
>   }
> }
>
> Record 2
> {
> key1:value1,
> key2:value2,
> key3: {
>   key3a:value3a,
>   key3b:value3b
> }
> key4:{
>    key4b1:value4b1,
>    key4b2:value4b2
>   }
> }
>
> Kind regards
> Jens M. Kofoed

Reply via email to