Accessing Data in a complex Collection structure

Dear Make-Community,

I am facing a problem regarding the procession of an API response I’ve integrated in Make via a HTTP request. The response of the request looks like the following example:


[ 
    {
       "statusCode": 200,
       "headers": [...],
       "cookieHeaders": [...],
         "data": {
             "data": {
                 "search": {...},
                 "fetch": {
                     "article-8456875": {
                         "data": {
                           "title": "test",
                           "description":"this is a test."
                         }
                     },
                     "article-8456807": {
                         "data": {
                             "title": "test2",
                             "description": "this is a second test",
                         }
                     }
                 }
             }
         }
     }
 ]

Here’s what I want to achieve:
I want to iterate the response i a way that every article “article-xxxxxxxx” is treated equally and the title and description for each article can be processed in a following module separately.

Here’s what I’ve already tried:
a simple iterator does not work at all because of the structure of the HTTP response. That’s why I’ve tried using the toArray() function within the Iterator:

Its output consists of two bundles:

In the following modules unfortunately only “Value”, “Bundle order position” and “Total number of bundles” are available for further mapping, I can’t go any level deeper than “value”.

Is there any solution to achieve my goal of iterating each article, so I can get its title and description to further process/map it?

Tank you so much for your help!
Best regards,

Sascha

@Sascha_Fuchs
Hi, I have attached a blueprint for your reference, please check it.
blueprint_nestedCollection.json (7.9 KB)

It seems that the collections are nested and when converted to arrays, the data cannot be taken from the subordinate collections. I don’t know if this is a specification, but I was able to reproduce the same situation as you.
So, if you get the values directly from the HTTP module without converting them to arrays, and then execute repeater according to the length of the collections, you can get the values from each collection by repeater.

Well, there is a “hack” for this but it takes one additional operation per item.

You simply need to reference {{5.value.data}} in a Set Variable module.

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

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.