Skip to content

splitObject

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.

{input | splitObject:delimiter:index:fallback}
  • input (object): The object containing values to split
  • delimiter (string): The character or string to split by
  • index (number, optional): Zero-based index of the element to return from each split
  • fallback (string, optional): Default value if input is invalid, property is empty, or index is out of bounds (defaults to “N/A”)
  • 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
{{"name": "John-Doe", "email": "john@example.com"} | splitObject:"-"}
// Returns: {"name": ["John", "Doe"], "email": ["john@example.com"]}

Get specific element by index from all strings

Section titled “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"}
{{"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
{{"code": "ABC-123-XYZ", "ref": "REF-001"} | splitObject:"-":5:"Not found"}
// Returns: {"code": "Not found", "ref": "Not found"}
{vulnerability | splitObject:".":0:"Unknown"}
// Splits all string properties in a vulnerability object by "." and returns first segment
{{"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
{{
"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"
// }
  • 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