Menu

Search toolsChangelog

to move to openDescribe the problem, not the tool

Guide answer

Array of Objects or Arrays for Tabular JSON?

Use an array of objects for most tabular JSON: keys carry the column names, missing fields stay visibly missing, and adding a field does not shift the meaning of every later value. Use an array of arrays only when position is already the contract, every consumer has the same external schema, and compact size matters enough to justify making the data harder to inspect. CSV itself is positional, but JSON does not have to repeat that weakness.

What to take away
  1. Object keys make a record self-describing and let sparse rows omit a field without moving another value under its heading.

  2. Arrays are smaller but position zero has no meaning unless a separate, versioned schema supplies one.

  3. Converting a headered CSV to objects is usually the safer default; arrays suit controlled machine-to-machine pipelines.

The full explanation

A CSV file is a rectangle, while JSON is a tree. Moving between them is easy only after somebody decides what a row is, where the complete set of columns comes from, and how nested values fit into flat cells. Those decisions are part of the data model, not punctuation a converter can infer perfectly. Read the complete guide for the reasoning, examples and definitions behind this answer.

Use the idea

Sources