Having trouble converting this JSON to a comma seperated string

I have a JSON result from a node, that I am trying to convert into a comma seperated string of values.

I need only the “id” value, so my end result will look like this:

3455201913137028,7958801540507524,640452146030468

I’ve tried a function, but since my set of items doesn’t have a overall key (like results or data), I am unable to use the map function successfully I’ve used in the past.

Any assistance on what I think should be a pretty simple function block would be appreciated thanks!

My failed attempt:

return [
  {
    json: {
      therows: items.map((e) => items.id).join(',')
    },
  }
]

Returns this:

    {
    "therows": ",,"
    }
    ]

Here’s the sample data:

[
{
"id": 3455201913137028,
"rowNumber": 1,
"expanded": true,
"createdAt": "2021-07-29T00:28:55Z",
"modifiedAt": "2021-07-29T00:28:55Z",
"cells": [
{
"columnId": 3617490554120068,
"value": "ACSYARD-INBOX-705-Big4-003072",
"displayValue": "ACSYARD-INBOX-705-Big4-003072"
}
]
},
{
"id": 7958801540507524,
"rowNumber": 2,
"siblingId": 3455201913137028,
"expanded": true,
"createdAt": "2021-07-29T00:28:55Z",
"modifiedAt": "2021-07-29T00:28:55Z",
"cells": [
{
"columnId": 3617490554120068,
"value": "ACSYARD-INBOX-705-Big4-003073",
"displayValue": "ACSYARD-INBOX-705-Big4-003073"
}
]
},
{
"id": 640452146030468,
"rowNumber": 3,
"siblingId": 7958801540507524,
"expanded": true,
"createdAt": "2021-07-29T00:28:55Z",
"modifiedAt": "2021-07-29T00:28:55Z",
"cells": [
{
"columnId": 3617490554120068,
"value": "ACSYARD-INBOX-705-Big4-003074",
"displayValue": "ACSYARD-INBOX-705-Big4-003074"
}
]
}
]

Try:

return [
  {
    json: {
      therows: items.map(e => e.json.id).join(',')
    },
  }
]

Perfect! This solved it thanks so much! The Javascript map function is a lot of docs to wade through that are not easily relevant to n8n (in simple cases like this)

Glad that it worked. Have fun.