Extract Values from an Array of Collections using map() in Make
You have an array of 'users' collections. You need a simple array containing only the 'email' of each user using Make's map() function (Note: Make uses semicolons ; between parameters).
Incoming Payload / Data:
{
"users": [
{ "id": 1, "email": "[email protected]" },
{ "id": 2, "email": "[email protected]" }
]
}
Press Enter or click Check Answer. +20 XP
β Solution & explanation
Output: ["[email protected]", "[email protected]"]
map(array; key) loops over an array of collections and returns a new array containing only the value of key from each one. The key is the raw property name, not a mapped pill.π‘ Pro tip: Add a filter with the optional 3rd and 4th arguments: map(users; email; id; 1) returns only emails where id equals 1.
Also accepted: map(users;email), map(users; "email")