Last updated
Example: Array Reconstruction
// Input (flat with bracket notation):
{
"order.id": "ORD-001",
"order.items[0].product": "Widget",
"order.items[0].qty": 2,
"order.items[0].price": 10.00,
"order.items[1].product": "Gadget",
"order.items[1].qty": 1,
"order.items[1].price": 25.00
}
// Output (nested with arrays):
{
"order": {
"id": "ORD-001",
"items": [
{ "product": "Widget", "qty": 2, "price": 10.00 },
{ "product": "Gadget", "qty": 1, "price": 25.00 }
]
}
}
Example: Environment Variables to Config
// Input (environment variable style):
{
"DATABASE_HOST": "localhost",
"DATABASE_PORT": "5432",
"DATABASE_NAME": "myapp",
"DATABASE_CREDENTIALS_USER": "admin",
"DATABASE_CREDENTIALS_PASSWORD": "secret",
"SERVER_PORT": "8080",
"SERVER_DEBUG": "true"
}
// Output (nested config, delimiter: underscore):
{
"DATABASE": {
"HOST": "localhost",
"PORT": "5432",
"NAME": "myapp",
"CREDENTIALS": {
"USER": "admin",
"PASSWORD": "secret"
}
},
"SERVER": {
"PORT": "8080",
"DEBUG": "true"
}
}
Example: Elasticsearch Flat Query to Nested
// Elasticsearch uses dot notation for nested field queries.
// Input (flat Elasticsearch field names):
{
"user.name": "Alice",
"user.email": "alice@example.com",
"user.address.city": "New York",
"metadata.created_at": "2024-01-15",
"metadata.version": 2
}
// Output (nested JSON document):
{
"user": {
"name": "Alice",
"email": "alice@example.com",
"address": {
"city": "New York"
}
},
"metadata": {
"created_at": "2024-01-15",
"version": 2
}
}
Example: CSV Headers to Nested JSON
// CSV with dot-notation headers:
// user.name,user.email,address.city,address.zip
// Alice,alice@example.com,New York,10001
// Parsed as flat JSON:
{
"user.name": "Alice",
"user.email": "alice@example.com",
"address.city": "New York",
"address.zip": "10001"
}
// Unflattened:
{
"user": {
"name": "Alice",
"email": "alice@example.com"
},
"address": {
"city": "New York",
"zip": "10001"
}
}
Example: Type Inference
// Input (all values as strings — common from env vars or CSV):
{
"server.port": "8080",
"server.debug": "true",
"server.timeout": "30",
"server.ratio": "0.75",
"server.name": "myapp",
"server.tags": "null"
}
// Output (with type inference enabled):
{
"server": {
"port": 8080, // "8080" → number
"debug": true, // "true" → boolean
"timeout": 30, // "30" → number
"ratio": 0.75, // "0.75" → number
"name": "myapp", // stays string
"tags": null // "null" → null
}
}
// Output (with type inference disabled — all strings preserved):
{
"server": {
"port": "8080",
"debug": "true",
"timeout": "30",
"ratio": "0.75",
"name": "myapp",
"tags": "null"
}
}
Delimiter Options
// Same flat data with different delimiters:
// Dot notation (default):
{ "user.name": "Alice", "user.age": 30 }
→ { "user": { "name": "Alice", "age": 30 } }
// Double underscore:
{ "user__name": "Alice", "user__age": 30 }
→ { "user": { "name": "Alice", "age": 30 } }
// Forward slash:
{ "user/name": "Alice", "user/age": 30 }
→ { "user": { "name": "Alice", "age": 30 } }
// Custom separator (e.g., ":"):
{ "user:name": "Alice", "user:age": 30 }
→ { "user": { "name": "Alice", "age": 30 } }
Handling Keys with Dots in Names
// Problem: key "version.1.0" should not be split
// Input:
{
"config.version.1.0": "stable",
"config.name": "myapp"
}
// Without escape: splits on all dots
{
"config": {
"version": { "1": { "0": "stable" } },
"name": "myapp"
}
}
// With escape character (\):
// Input: { "config.version\\.1\\.0": "stable", "config.name": "myapp" }
// Output:
{
"config": {
"version.1.0": "stable",
"name": "myapp"
}
}
Paste your flat JSON with dot-notation keys to reconstruct the original nested structure. Configure the delimiter and type inference options to match your data source's format.
Example: Basic Unflattening
// Input (flat):
{
"user.name": "Alice",
"user.age": 30,
"user.address.city": "New York",
"user.address.zip": "10001",
"user.address.country": "US"
}
// Output (nested):
{
"user": {
"name": "Alice",
"age": 30,
"address": {
"city": "New York",
"zip": "10001",
"country": "US"
}
}
}