collect_keys - Liquid Filter Reference
On this page
Description
Plucks a set of values from a list of maps
| Property | Value |
|---|---|
| Return Type | list |
| Category | maps |
Examples
liquid
{{ products | collect_keys: "name", "type" | json }}
Output: [{"name":"Fridgetastic 3000","type":"whitegoods"},{"name":"Coldinator 500","type":"whitegoods"},{"name":"Geronimo 9000","type":"computers"},{"name":"Y2K Amaze","type":"computers"}]
liquid
{{ products | collect_keys: "name" | json }}
Output: [{"name":"Fridgetastic 3000"},{"name":"Coldinator 500"},{"name":"Geronimo 9000"},{"name":"Y2K Amaze"}]