I’m trying to loop through a list of attendees for a Google Calendar event and create an array of external attendees’ names and email addresses, before processing them. I know there’s lots of questions about constructing arrays on this forum but I couldn’t find a suitable example which showed how to do this.
I’m iterating over the attendees array -
Filtering out internal email addresses and then creating JSON objects -
Then aggregating the results into an array -
And now I have an array where the items look like this -
I thought I could simply insert that array as the body of my HTTP request, like this -
But for some reason that produces Request Content like this -
Which causes an error:
Unexpected token , in JSON at position 1
If I don’t wrap the array in square brackets, the Request Content is formatted like this -
I’ve tried making every type of change to the formatting that I can think of but I just can’t figure out how to create an array from these JSON objects?
(If there’s a more efficient way to construct this array, which uses less operations, I’d really appreciate any pointers on that too). Here’s an example of the meeting event -
[
{
"kind": "calendar#event",
"etag": "\"...\"",
"id": "...",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=...",
"created": "2021-01-21T00:31:15.000Z",
"updated": "2023-08-14T21:14:09.737Z",
"summary": "...",
"description": "..."><u>https://us02web.zoom.us/u/...</u></a>",
"creator": {
"email": "...@gmail.com"
},
"organizer": {
"email": "...@gmail.com"
},
"start": "...",
"end": "...",
"recurrence": [
"RRULE:FREQ=MONTHLY;UNTIL=...;BYDAY=2MO"
],
"iCalUID": "...",
"sequence": 0,
"attendees": [
{
"email": "...@gmail.com",
"responseStatus": "accepted"
},
{
"email": "...@gmail.com",
"organizer": true,
"responseStatus": "accepted"
},
{
"email": "...@gmail.com",
"responseStatus": "declined"
},
{
"email": "...@gmail.com",
"responseStatus": "needsAction"
},
{
"email": "...@gmail.com",
"self": true,
"responseStatus": "accepted"
},
{
"email": "...@gmail.com",
"responseStatus": "declined"
},
{
"email": "...@gmail.com",
"responseStatus": "needsAction"
}
],
"reminders": {
"useDefault": true
},
"eventType": "default"
}
]