StackPractices
Typed path contract 22/22 corpus 100% client-side

Flatten/Unflatten JSON Playground

Paste nested JSON, inspect its strict typed-bracket flat map, verify the round-trip, and run the same conformance corpus behind the flatten/unflatten recipe — without installing anything.

1. JSON input

Paste any JSON value. The parser validates as you type; when the value is valid, the flatten and round-trip verdict update automatically.

Use normal JSON syntax. Duplicate keys are whatever JSON.parse keeps; contract violations are reported after parsing.

Live flat map

Object keys stay typed: nested["456"] is a key, while tags[0] is an array index.

No flat entries yet. Valid JSON with a non-empty object or array root will appear here.

2. Round-trip verifier

The verifier runs flatten → unflatten and compares the restored value deeply with the original input.

—

3. Browser conformance corpus

Run the 22 cases from conformance-corpus.json against the same typed-bracket implementation ported from flatten.js. The corpus is small enough to embed directly in this client script, so the runner also works offline after the page loads.

Corpus not run yet.

Case Operation Expected Actual Match
Run the corpus to populate this matrix.

The playground is the executable companion to the recipe. The article explains when this format is appropriate, where libraries diverge, and why consumer-specific grammars should not be mixed.

Flatten JSON FAQ

Is this JSON flattener lossless?

It is lossless for JSON objects and arrays that follow the typed-bracket contract shown on the page. The verifier does not merely flatten the input: it unflattens the result and compares it deeply with the original value. Inputs outside the contract, such as scalar roots or circular structures, fail with an explicit error instead of pretending to round-trip.

Why do numeric object keys use brackets and quotes?

A key such as nested["456"] is an object key that happens to contain digits. Numeric brackets without quotes, such as tags[0], mean an array index. Keeping those types distinct is what prevents numeric object keys from turning into sparse arrays during unflattening.

Does the corpus runner upload my JSON?

No. The implementation and the 22 conformance cases run entirely in your browser. Nothing is sent to a server, and the runner exists so you can inspect the same contract locally instead of trusting the article claims.

When should I use this strict format?

Use it in a controlled pipeline, fixture, patch format, or internal exchange where you own both writer and reader. Do not paste it blindly into MongoDB dot notation, browser forms, CSV exports, or JSON Pointer consumers; those systems own different path grammars.