Keep track of the parent_id / parent_name when flattening

Hello everyone,

I’m trying to work with a JSON file coming from an API.
The JSON has a hierarchical structure, with nested objects inside children arrays, sometimes across multiple levels. For example: a page contains blocks, which contain components, which in turn contain elements, and so on.

My initial approach was to use an Array Aggregator combined with an Iterator to loop through each level.
However, since the JSON can be quite large (with potentially hundreds of elements and sub-elements) and its structure is dynamic, this method would consume far too many operations.

I then switched to a solution based on flatten(map(...)) to flatten each level.
My main issue now is this: I would like to keep the parent information for each flattened element (such as parent_id and parent_name), but I haven’t been able to do it successfully.

I’ve tried several methods, but nothing seems to work.
Do you have any ideas or suggestions on how to approach this?

Thanks so much in advance for your help :folded_hands:




Exemple.json (2.8 MB)

You’ll have to use an Iterator-Aggregator, and not the flatten built-in function.

This is because by using the map function, you are selecting/extracting ONLY the children information from the array, and discarding the rest of the parent data.

Hope this helps! Let me know if there are any further questions or issues.

@samliew