Flatten an array of collections to a single array of values

Hello all, I am really struggling get this to work.

I have an iterator which uploads a set of images to Twitter, then I aggregate the returned media IDs. I would like to have an array of media ID values, instead I get the following bundle content out of my aggregator.

[
    {
        "array": [
            {
                "media_ids": [
                    "1799506850057957376"
                ]
            },
            {
                "media_ids": [
                    "1799506864981282817"
                ]
            },
            {
                "media_ids": [
                    "1799506878604464128"
                ]
            }
        ],
        "__IMTAGGLENGTH__": 3
    }
]

Ideally, iā€™d want my output to be just an array in the form

"media_ids":["id1", "id2", "id3"]

Welcome to the Make community!

You can use the built-in function map,

e.g.:

{{ map(2.array; "media_ids.1") }}

samliew ā€“ request private consultation

Join the unofficial Make Discord server to chat with us!

2 Likes