Flattening a nested data structure

Hello the Make community :wink:

I’ve a problem with flattening a nested data structure without using the Iterator module, in order to minimize the number of operations (and tokens).

My Use Case

I receive an “array of orders”, each containing an array of “tickets”. My goal is to create a “flat array” where each ticket is on its own line, while retaining key information from the parent order.

Example (input):
“id”: 80196362,
“plan”: { “name”: “Expo1” },
“partner”: { “name”: “the experience” },
“tickets”: [
{ “id”: 1, “unitary_price”: 29.9 },
{ “id”: 2, “unitary_price”: 19.9 }
]
In my step post array agregator i get this:


And without flatening the structure, i get a code that works, but return only the first ticket and look like:

Expected (output):
{ “ticket_id”: 1, “ticket_price”: 29.9, “plan_name”: “Expo1”, “partner_name”: “the experience” },
{ “ticket_id”: 2, “ticket_price”: 19.9, “plan_name”: “Expo1”, “partner_name”: “the experience” }
]

I tested multiples things since 2 weeks without success, so a help in this would be really appreciated:)

Hey there,

blueprint (2).json (5.6 KB)

Something like this should rearrange the incoming array in the desired structure. Make sure to add any extra variables you need to the iterator that were missing in the example output you provided. You can also change the set variables module to set multiple variables to rename all of them as needed.