How to map JSON fields when names are changing


I’m trying to get URLs from Reddit and send them to Airtable.
When there is only one image URL in the Reddit post, I can map that one to one and save it in Airtable without a problem.

When there is a gallery in the post (i.e. multiple image URLs), the names of the nested objects within the JSON change with every post (see image below).

For this post, the nested object’s names are ‘0891a92mzzral’, ‘a3elhb2mzzral’ etc., however, the next post has different names for these objects.

This means, when I run the scenario for this one post, it will get saved, but any other post with multiple images will not.

Is it at all possible to map this?

Not sure if it is the best solution but what you can do is utilize the keys() function with an array iterator and aggregator to get the Image URL, In your example provided that u is the image what you can do is.

Grab all the keys for collection media_metadata and then use the get function to access u variable.

So, Your Scenario should look like this,

  1. Array Iterator with input as {{keys(3.media_metadata)}}
  2. Set Variable, with the following formula to grab u, {{get(3.media_metadata; 6.value + ".s.gif")}}
  3. An array aggregator to aggregate the result URLs

You can try this blueprint to see how it functions.

blueprint (33).json (6.6 KB)

OMG it took me a long time to get it working, but THANK YOU VERY MUCH