Lava Filters - Last
Category:Arrays
Description:Returns the last 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 | Last %}
The last phone number is {{ firstPhone.NumberFormatted }}.
Output: The last phone number is (555) 555-5553.