Repository navigation
feat(json2csv): add contextual Flatten nested keys pill and deep dot-flattening - #232
Merged
obvious-autobuild-staging[bot] merged 1 commit intoOct 20, 2026
Merged
Conversation
…flattening Add detectNestedJsonKeys and recursive plain-object dot-flattening in convert.ts so nested plain objects (e.g. user.profile.name) and scalar arrays flatten cleanly in JSON -> CSV mode without throwing NonTabularJsonError, and surface a one-click Flatten nested keys toggle pill above the JSON editor in InputPane when nested keys are detected. Co-authored-by: David Boskovic <david@obvious.ai>
obvious-autobuild-staging
Bot
force-pushed
the
feat/json2csv-flatten-pill
branch
from
October 20, 2026 02:49
decde08 to
d4f4c1e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human author: David Boskovic (david@obvious.ai)
Why
When users paste JSON containing nested objects (
{ "user": { "profile": { "name": "Ada" } } }) or scalar arrays ({ "tags": ["math", "code"] }) intoJSON → CSVmode, two friction points occur:Flattenoption is tucked insideParse settings, unlikeCSV → JSONmode (csv-indexed-array-pill) and wrapped root objects (json-unwrap-pill) which surface contextual one-click pills directly above the editor.Flattenpreviously only joined top-level scalar arrays viajoinScalarArrays, leaving nested plain objects unflattened as raw JSON strings in CSV cells (or throwingNonTabularJsonErrorwhen nested structures were encountered).What
app/src/lib/convert.ts):flattenNestedObjectsbeforejoinScalarArrayswhenoptions.flatten === trueinjsonToCsv. Nested plain objects of arbitrary depth expand into dotted column keys (user.profile.name,user.profile.city), nested scalar arrays join with", ", empty plain objects ({}) normalize to"", and arrays of plain objects continue to usecsvjson-json2csv's cartesian row expansion with their inner nested objects also dot-flattened.detectNestedJsonKeysinapp/src/lib/convert.ts):Flatten nested keyspill (app/src/components/InputPane.tsx&app/src/App.tsx):data-testid="json-flatten-bar"anddata-testid="json-flatten-pill"(aria-pressed={flatten}) above the JSON editor whendirection === "json2csv"and nested keys are detected, displaying up to 3 key names (Flatten nested keys (.user, .tags)) with", +N more"overflow and active pressed styling (Flattened nested keys (...)) when enabled.#19inapp/src/changelog/entries.tsand rebuiltapp/dist.app/src/lib/__tests__/convert.test.tsand component integration tests inapp/src/App.test.tsx.Tradeoffs
options.flattenvs. separate state: Binding the pill directly tooptions.flattenkeeps the contextual strip above the JSON editor and theParse settingscheckbox in lockstep without duplicating state.{ "data": [...] }),detectNestedJsonKeysreturns[]so only theUnwrap .data (N rows)pill is shown first; once unwrapped, if individual records contain nested objects or arrays, theFlatten nested keyspill appears.How to Review
app/src/lib/convert.ts—detectNestedJsonKeys,flattenRecordPlainObjects,flattenNestedObjects, andjsonToCsvpipeline order.app/src/components/InputPane.tsx&app/src/App.tsx— contextualjson-flatten-bar/json-flatten-pillrendering andonToggleFlattenwiring.app/src/lib/__tests__/convert.test.ts&app/src/App.test.tsx— unit and component test coverage for AC-15 / D14.Verification
cd app && npm run lint && npx tsc -b --noEmit && npm test && npm run build(34 test suites, 575 tests passing)bash .github/scripts/verify-seo.sh1440×900viaagent-browserverifying nested key detection, one-click flatten toggle, dotted CSV table columns (USER.PROFILE.NAME,USER.PROFILE.CITY), and scalar array joining (TAGS).🔗 Obvious Project · 🧵 Obvious Thread · 🔀 Obvious PR Artifact