pluck
The pluck function extracts a specific property from each object in an array, returning a new array containing only those values.
Syntax
Section titled “Syntax”{input | pluck:property}Parameters
Section titled “Parameters”input(array): An array of objects to extract values fromproperty(string): The property name to extract from each object
Returns
Section titled “Returns”- Array containing the specified property value from each object
- Returns input unchanged if not an array or if input is null/undefined
- For non-object array items, returns the item unchanged
Examples
Section titled “Examples”Extract names from users
Section titled “Extract names from users”{[ {"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}, {"name": "Charlie", "age": 35}] | pluck:"name"}// Returns: ["Alice", "Bob", "Charlie"]Extract IDs from vulnerabilities
Section titled “Extract IDs from vulnerabilities”{vulnerabilities | pluck:"id"}// Returns array of vulnerability IDs: ["001", "002", "003"]Extract severity levels
Section titled “Extract severity levels”{findings | pluck:"severity"}// Returns: ["Critical", "High", "Medium", "Low"]Extract nested property
Section titled “Extract nested property”{[ {"user": {"email": "alice@example.com"}}, {"user": {"email": "bob@example.com"}}] | pluck:"email"}// Returns: ["alice@example.com", "bob@example.com"]Chain with other filters
Section titled “Chain with other filters”{vulnerabilities | pluck:"title" | implode:", "}// Returns comma-separated list of vulnerability titlesMixed array types
Section titled “Mixed array types”{[ {"name": "Item 1"}, "string item", {"name": "Item 2"}] | pluck:"name"}// Returns: ["Item 1", "string item", "Item 2"]Non-array input
Section titled “Non-array input”{{"name": "Single Object"} | pluck:"name"}// Returns: {"name": "Single Object"} (unchanged)Use Cases
Section titled “Use Cases”- Extracting specific fields for display in lists
- Creating arrays of IDs for further processing
- Simplifying complex data structures in reports
- Preparing data for charts (e.g., extracting labels or values)
- Building dropdown options from object arrays
- Combining with
implodeto create formatted lists
- Returns input unchanged if input is null or undefined
- Non-array inputs are returned as-is
- If an array item is not an object, it’s included unchanged in the output
- Useful for data transformation in report templates
- Often combined with other filters like
implodeorjoinWith