Report templatesFunctions
splitObject
Split all string values in an object based on a delimiter and optionally return specific elements
Usage
The splitObject
function processes an object and splits all string values using a specified delimiter. It returns a new object with the split values, while preserving non-string values as-is.
Syntax
{input | splitObject:delimiter:index:fallback}
Parameters
input
(object): The object containing values to splitdelimiter
(string): The character or string to split byindex
(number, optional): Zero-based index of the element to return from each splitfallback
(string, optional): Default value if input is invalid, property is empty, or index is out of bounds (defaults to "N/A")
Returns
- If input is not an object: Returns the fallback value
- If
index
is provided: Returns an object with each string value replaced by the element at the specified index (or fallback) - If
index
is not provided: Returns an object with each string value replaced by an array of split elements - Non-string values are preserved unchanged
Examples
Basic object splitting
{{"name": "John-Doe", "email": "john@example.com"} | splitObject:"-"}
// Returns: {"name": ["John", "Doe"], "email": ["john@example.com"]}
Get specific element by index from all strings
{{"version": "v1.2.3", "tag": "release-2024-01"} | splitObject:"-":0}
// Returns: {"version": "v1.2.3", "tag": "release"}
Mixed data types with splitting
{{"count": 5, "path": "/home/user/docs", "active": true} | splitObject:"/":2}
// Returns: {"count": 5, "path": "user", "active": true}
// Note: Non-string values (count, active) remain unchanged
Using with fallback
{{"code": "ABC-123-XYZ", "ref": "REF-001"} | splitObject:"-":5:"Not found"}
// Returns: {"code": "Not found", "ref": "Not found"}
Processing vulnerability data
{vulnerability | splitObject:".":0:"Unknown"}
// Splits all string properties in a vulnerability object by "." and returns first segment
Parsing version strings in an object
{{"app_version": "2.5.1", "api_version": "1.3.0", "build": 42} | splitObject:".":1:"0"}
// Returns: {"app_version": "5", "api_version": "3", "build": 42}
// Gets the minor version number from version strings
Complex object with nested paths
{{
"file_path": "/var/log/system.log",
"backup_path": "/backup/2024/january/data.tar",
"size": 1024,
"type": "log-file-backup"
} | splitObject:"/":3:"N/A"}
// Returns: {
// "file_path": "system.log",
// "backup_path": "january",
// "size": 1024,
// "type": "log-file-backup"
// }
Use Cases
- Processing multiple file paths or URLs in configuration objects
- Extracting specific segments from versioned identifiers
- Batch processing string properties while preserving other data types
- Transforming imported data with consistent string patterns