Skip to main content

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

NameTypeRequiredDefaultDescription
delimiterstringfalse"_"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

  1. The transformation flattens all nested structures in the document
  2. Array indices are zero-based in the flattened output
  3. Primitive values (strings, numbers, booleans) are left unchanged
  4. Null values are preserved in the flattened output
  5. Delimiter defaults to "_"