Extracting items from deeply nested arrays and collections


I know this is a frequent question but I’ve really hit a wall. I am actually not exactly sure how I’m going to handle Calendly availability checking yet with the agent I’m building, but I’m stuck because I can’t seem to get the data returned to parse down far enough to actually show what’s under the intervals (the to and from hours).

I’ve tried iterators, aggregators, flatten, mapping, get/map, toCollection, toArray and those values always come back empty. I apologize I can’t even remember the combinations of things I’ve tried. It’s kind of descended into several hours of just mashing things together and nothing working. I know I must be missing something really simple.

What I need to be able to do is take the Availability payload returned from Calendly and create a fully mappable output so I can then determine how I’m going to move forward with my scenario.

I really appreciate all the smart people here :smiley: Thanks!

output.json (3.8 KB)

Something like this perhaps?

{{ first(map(1.body.collection.1.rules; intervals; wday; monday)) }}
1 Like

@samliew has a great answer above but can I recommend my Make for Newbies video series to learn about accessing data structures? It will enlighten and serve to increase your understanding so you don’t just end up mashing stuff together willy nilly and act from a position of knowledge/experience.

Actually it’s not simple at all. The Make element picker UI (the :star: icon in the Make element picker) doesn’t make this easy at all!

If you don’t understand the object path (ie dot notation) to reference the correct array for the map() function. You see 1.body.collection.1.rules argument in the map() function that @samliew entered? That’s not something you can click on in the Make UI and have to write it out.

But it means this:

Look in module 1 (1.)
then look in the collection called body (body.)
then look in the array called collection (collection.)
then look in the first element of the collection array (1.)
then look in the array called rules (rules.)

The object path 1.body.collection.1.rules tells the map() to look in that nested array called rules.

The second/third/fourth arguments to map tells it to select the intervals array but only for elements on the rules array where the wday key is equal to monday

The first() call that surrounds the map() call extracts the 1st element from the array which is the from: and to: values (09:00 and 10:00 in your example)

If you use last() around the same map() function you will get 12:00 and 14:00 which is the last element of the intervals array.

Make sense? Seriously watch my Make for Newbies series right from start. You’ll be happy you did.

Alex Sirota
Director of NewPath Consulting - we are :superhero: Make Heroes! :woman_superhero:t4:

:heart_on_fire: Check out my series of videos and scenario walkthroughs for Make Newbies :heart_on_fire:

My Solutions on Make Community


Thank you @samliew, I will give this a try when back in the office tomorrow!

@alex.newpath Yes. It 100% makes sense. Believe it or not, I can actually code. so I understand traversing data structures but I get lost in Make sometimes. My company is really scaling up using it so your videos could not have come at a better time. I’ll be watching all of them this week. Thanks so much for doing that!!

Oh then this will make it easier for you. Basic understanding of manipulation of data structures found in JSON is crucial for using make effectively. Good luck! I’m sure you’ll be a pro in no time at all. Practice makes perfect!

1 Like