List of items formatted into JSON array

Hi, I am using an API to assign users roles on discord. The format to do this in JSON is.

"roles": [


Essentially the roles bit is an array, and the numbers are the items within that. How does this correspond to Bubble?

I’d be saying take Current User’s Group’s:each item’s discord ID

For each group, a new line would be created, filling up the array with the corresponding discord ID.

How can I even begin to achieve this?

The :format as text operator enables you to convert any list into a delimited string

Thanks, I’ve got it working now as it turns out that I managed to do it, but I now face another issue.

So I’m saying let’s take the user’s group’s:each item’s id plus item user’s rank’s id plus item user’s branch’s id join with ,

In this case, the user has NO groups and NO branches, so the only value I’d expect to see would be the Rank’s ID, which is what I get. However, this has a comma at the end of it despite there being no other value after this.

Edit: Doing a quick “count” shows that there is two items in my list, this makes no sense because I don’t understand how I can add an empty item to my list.