Can the map function be nested? Or maybe there is a different way to think about this?
I’m trying to cycle through two nested arrays and I can only grab the first value of the second array. On the below json, I’m trying to cycle through both the ‘games’ array and the ‘promotions’ array. The code that I have is below (which somewhat works as it will grab the 1st promotion name, but won’t grab the second. The code is the same basically as the above, but the difference is that the values in the promotion can be an array.
Thoughts on how to handle?
What I’m looking to return is:
2023 Magnetic Schedule Gate Giveaway
2023 Magnetic Schedule Gate Giveaway
Friday Night Fireworks (this is what isn’t returned in the below code)
schedule = $context.response.data.dates
myString = map(schedule, x.games[0].promotions[0].name)
join(myString, "\r\n")
The json that the above code is referencing is (coming from here):
{
"dates": [
{
"date": "2023-04-06",
"games": [
{
"gamePk": 718681,
"gameDate": "2023-04-06T23:20:00Z",
"officialDate": "2023-04-06",
"promotions": [
{
"name": "2023 Magnetic Schedule Gate Giveaway",
"description": "All in attendance will receive a 2023 magnetic schedule. ",
"order": 0,
"offerType": "Giveaway"
}
],
"description": "Braves home opener"
}
]
},
{
"date": "2023-04-07",
"games": [
{
"gamePk": 718676,
"gameDate": "2023-04-07T23:20:00Z",
"officialDate": "2023-04-07",
"promotions": [
{
"name": "2023 Magnetic Schedule Gate Giveaway",
"description": "All in attendance will receive a 2023 magnetic schedule. ",
"order": 0,
"offerType": "Giveaway"
},
{
"name": "Friday Night Fireworks",
"description": "Following every Friday night game, the sky above Truist Park lights up with the #1 rated fireworks show in the Southeast! Every show is different. See them all!",
"order": 1,
"offerType": "Day of Game Highlights"
}
]
}
]
}
]
}