Hi,
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.
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:
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:
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.
With my suggestion you save one OP as I need just one iteratorâŚ