I think you can use the groupby(). It's returning a list like this:
[ 10, [{id=1, ...},{id=2}], 20, [{id=3}]
Updated test data to include "memberId":
[
{
"id": 1,
"memberId": 10,
"name": "bob",
"city": "Boston"
},
{
"id": 2,
"memberId": 20,
"name": "jane",
"city": "Boston"
},
{
"id": 3,
"memberId": 30,
"name": "george",
"city": "Baton Rouge"
},
{
"id": 4,
"memberId": 10,
"name": "bob",
"city": "Boston"
}
]
OPTION A
If you just need the unique memberIds:
{{ users | map(attribute='memberId') | unique | list }}
Results:
[10, 20, 30]
OPTION BIf you need the record data and not just the ids:
{% for memberId, user in users | groupby('memberId') -%}
{{ user[0] }}
{% endfor -%}
The 'user[0]' is to reference the first object in the list for that memberId since you don't need them all.
Results:
{'id': 1, 'memberId': 10, 'name': 'bob', 'city': 'Boston'}
{'id': 2, 'memberId': 20, 'name': 'jane', 'city': 'Boston'}
{'id': 3, 'memberId': 30, 'name': 'george', 'city': 'Baton Rouge'}
Notice record with id=4 does not display.
UPDATE
Turns out unique takes a parameter for an attribute, so for Option B you could do this instead of the for loop to get the unique records:
{{ users | unique(false, attribute='memberId') | list }}
Hope that helps!
------------------------------
Doug Henning
------------------------------