Transforms
Flatten
Flatten a nested map or array into a flat map.
Overview
Flatten targets one key in the record and lifts that key's children up to the top level, joining the target key with each child key using the delimiter. The original key is removed.
The delimiter is applied to the first level only — anything nested below the target key's immediate children stays nested in the output. To flatten an entire record recursively, use Flatten All instead; that is usually what you want.
Configuration
| Argument | Type | Required | Default | Description |
|---|---|---|---|---|
| key | string | true | — | The key to flatten |
| delimiter | string | false | — | Characters used to join the target key with its first-level child keys |
Example
Code
Given the input record:
Code
The output record will be:
Code
nested_data and level1 are joined with the delimiter into nested_data_level1, and the
nested_data key is dropped. level2 and array sit one level deeper, so they are left as they
are rather than being folded into the key name.
Notes
- Only the first level is joined with the delimiter; deeper levels remain nested. Reach for Flatten All when you need every level collapsed.
- No default delimiter is applied. Omitting
delimiterjoins the keys with nothing at all — a record of{"address": {"city": "New York"}}flattened onaddressproduces the keyaddresscity. Always setdelimiterexplicitly. - The target key is removed from the record after its children are lifted.
Last modified on