Iterating nested Collections

I need to iterate items in a deeply nested collection. How can I access them? I tried with map(), but there is always one layer too much in the result to iterate it.

1 Like

Welcome to the Make community!

Please provide the output bundles of the module shown in your screenshot above by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

This will allow others to better assist you. Thanks!


Sure, sorry. Here is the JSON output.
output.txt (27.9 KB)

I tried to map the collection I need:

but what I get is a too nested output to iterate it:

I cannot use get() directly here to get the values of total, which would work - but there can be more or less collections so I dont know how much “totals” there will be.

Have you tried using ‘map’ directly on nested array? sth like:
Screenshot 2024-04-17 at 09.14.21


Yes, but I am getting the error “is not a valid array”. If I put toArray() before it, it is not “a valid collection”.

Ah, what I can see on your export data is that value is not always an array, that’s why you get this error.


I found this solution.
First, “toArray” for the wanted collection:

then iterate it:

gives the expected output:


Congrats, good case tho

You can even skip the first step and put it together into the iterator:

1 Like

Iterators work equally well on arrays and collections I found out recently.

You can import this scenario blue print into your own scenario and take a look at how you can iterate the metadata[] array, then just filter on the bundle number and then iterate the collection you wish to have access to.

blueprint (30).json (33.2 KB)


Yes, also a solution. :grinning:
With my suggestion you save one OP as I need just one iterator…