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.
Syntax
Section titled “Syntax”{input | splitObject:delimiter:index:fallback}Parameters
Section titled “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
Section titled “Returns”- If input is not an object: Returns the fallback value
- If
indexis provided: Returns an object with each string value replaced by the element at the specified index (or fallback) - If
indexis not provided: Returns an object with each string value replaced by an array of split elements - Non-string values are preserved unchanged
Examples
Section titled “Examples”Basic object splitting
Section titled “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
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"}Mixed data types with splitting
Section titled “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 unchangedUsing with fallback
Section titled “Using with fallback”{{"code": "ABC-123-XYZ", "ref": "REF-001"} | splitObject:"-":5:"Not found"}// Returns: {"code": "Not found", "ref": "Not found"}Processing vulnerability data
Section titled “Processing vulnerability data”{vulnerability | splitObject:".":0:"Unknown"}// Splits all string properties in a vulnerability object by "." and returns first segmentParsing version strings in an object
Section titled “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 stringsComplex object with nested paths
Section titled “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
Section titled “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