Flatten All
Overview
The Flatten All transformation flattens an entire JSON document into a single level structure. It handles both nested objects and arrays, using a specified delimiter to separate nested levels in the resulting keys.
Configuration
{
"operation": "flatten-all",
"arguments": {
"delimiter": "_"
}
}
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| delimiter | string | false | "_" | Character(s) used to separate nested levels in flattened keys |
Examples
Basic Object Flattening
Input:
{
"name": "John",
"address": {
"street": "123 Main St",
"city": "New York",
"zipcode": "10001"
}
}
Output with delimiter: "_":
{
"name": "John",
"address_street": "123 Main St",
"address_city": "New York",
"address_zipcode": "10001"
}
Array Flattening
Input:
{
"name": "John",
"contacts": [
{"type": "email", "value": "john@example.com"},
{"type": "phone", "value": "555-1234"}
]
}
Output with delimiter: "_":
{
"name": "John",
"contacts_0_type": "email",
"contacts_0_value": "john@example.com",
"contacts_1_type": "phone",
"contacts_1_value": "555-1234"
}
API
To create a Flatten All transform via the API:
curl -X 'POST' \
'{base_url}/api/v1/{org_id}/transforms' \
-H 'accept: application/json' \
-H 'Authorization: Bearer token' \
-H 'Content-Type: application/json' \
-d '{
"config": {
"operations": [
{
"operation": "flatten-all",
"arguments": {
"delimiter": "_"
}
}
]
},
"description": "Flatten entire JSON document",
"name": "flatten_all_transform"
}'
Notes
- The transformation flattens all nested structures in the document
- Array indices are zero-based in the flattened output
- Primitive values (strings, numbers, booleans) are left unchanged
- Null values are preserved in the flattened output
- Delimiter defaults to "_"