Lava Filters - First
Category:Arrays
Description:Returns the first item from an array/collection.
Input: "CurrentPerson": {
"PhoneNumbers": [
{
"NumberFormatted": "(555) 555-5551"
},
{
"NumberFormatted": "(555) 555-5552"
},
{
"NumberFormatted": "(555) 555-5553"
}
]
}
Lava: {% assign firstPhone = CurrentPerson.PhoneNumbers | First %}
The first phone number is {{ firstPhone.NumberFormatted }}.
Output: The first phone number is (555) 555-5551.