Skip to content

Detect and expand JSON-serialized nested columns#46

Open
Mandyx22 wants to merge 3 commits into
mainfrom
unnest-variables
Open

Detect and expand JSON-serialized nested columns#46
Mandyx22 wants to merge 3 commits into
mainfrom
unnest-variables

Conversation

@Mandyx22
Copy link
Copy Markdown

@Mandyx22 Mandyx22 commented May 29, 2026

  • Flat JSON object columns (e.g. response: {"Q0":4,"Q1":3}) are now expanded into dotted sub-variables (response.Q0, response.Q1) in variableMeasured, with correct types and min/max tracking. The parent variable is registered with value: "object" and no levels.

  • JSON array-of-objects columns (e.g. mouse_tracking_data: [{x,y,t},...]) are extracted into separate Psych-DS compliant CSV files named {stem}_measure-{col}_data.csv, with trial_index and element_index as join keys back to the parent file.

  • Both cases work from JSON and CSV input — CSV JSON strings are detected and parsed during the existing type coercion step.

  • Run npm test — all 30 tests pass including new metadata-nested-columns.test.ts

  • Run CLI against dev/ian-chat/OSF data.csv and confirm response sub-variables appear in dataset_description.json

  • Run CLI against dev/v8-data/mouse_extension/Mouse Extension.json and confirm a separate _measure-mouse-tracking-data_data.csv is created

Mandyx22 and others added 2 commits May 29, 2026 14:34
Flat JSON objects (e.g. response: {Q0:4, Q1:3}) are now expanded into
dotted sub-variables (response.Q0, response.Q1) in variableMeasured with
correct types and min/max tracking. JSON arrays of objects are extracted
into separate Psych-DS compliant CSV files ({stem}_measure-{col}_data.csv)
with trial_index and element_index as join keys.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: 75e37f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@jspsych/metadata Minor
@jspsych/metadata-cli Minor
frontend Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

…ation

typeof never returns "array" so TypeScript rejected the assignment and
comparison. Widening to string allows the custom "array" tag used to
distinguish array-of-objects columns from plain objects.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jodeleeuw
Copy link
Copy Markdown
Member

@Mandyx22 Can you show an example of what the final result looks like when there are nested tables?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants