Aller au contenu
POST AI agent ready /v1/json-extra/unflatten

JSON Unflatten API - Rebuild Nested Structure from Dot Keys

Inverse of /v1/json-extra/flatten. Splits each key by the delimiter, walks the path, and builds the nested structure. Segments that parse as non-negative integers become array indices; everything else becomes an object key.

Parameters

objectrequired

Flat object with dotted keys.

string

Path separator used in the keys.

Code examples

curl -X POST https://api.botoi.com/v1/json-extra/unflatten \
  -H "Content-Type: application/json" \
  -d '{"json":{"user.name":"Ada","user.tags.0":"founder","user.tags.1":"engineer"},"delimiter":"."}'

When to use this API

Parse form data into a nested payload

HTML form names like "user.address.city" come in flat. Collect them into a flat object, then unflatten to the JSON shape your API expects. No framework-specific form library required.

Import CSV back into nested JSON

After flattening nested JSON into CSV for editing in Excel, read the rows back as flat objects and unflatten each one to restore the original structure.

Environment variables to nested config

Convention: MYAPP_DB_HOST, MYAPP_DB_PORT. Strip the prefix, lowercase, replace underscores with dots, and unflatten to get the config object your app expects.

Frequently asked questions

How does array detection work?
If all keys at a level match ^\d+$ (all digits, no leading zeros), the node is converted to an array indexed by those numbers. Missing indices become sparse (undefined slots).
What if I have literal digit keys I want as strings?
Use a non-numeric prefix in the flat key ("tag_0" instead of "tags.0"). The all-numeric heuristic only triggers when every sibling key is numeric.
Does this handle arbitrary delimiters?
Yes. Pass delimiter matching whatever you used for flattening. Both sides must agree; mixing delimiters returns unexpected structure.
What happens on conflicting paths?
If "a" is set to a scalar and "a.b" is set to another, the scalar is overwritten by an object. The last write wins; the order follows object key iteration.
Is there a size limit?
No hard limit, but the request body must fit in the standard 10 MB Cloudflare Workers limit. For very large flat maps, chunk and unflatten in batches.

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.