Extract a Field from Every Object with map() in n8n
You need a simple list of emails from a users array to send a bulk notification.
Incoming Payload / Data:
{
"users": [
{ "id": 1, "email": "[email protected]" },
{ "id": 2, "email": "[email protected]" }
]
}
βοΈ Your expression is executed against test data β any correct solution passes. +20 XP
β Solution & explanation
Output: ["[email protected]", "[email protected]"]
map() returns a new array with the result of the arrow function for each element. u => u.email takes each user and returns only its email. n8n also offers .pluck('email').π‘ Pro tip: Join them into one string for an email field: $json.users.map(u => u.email).join(', ').
Also accepted: map(user => user.email), pluck('email')