How JSON maps to rows and columns
| JSON | Becomes |
|---|---|
| An array of objects | One row per object |
| A single object | One row |
| Each key | A column (the union of all objects' keys) |
| A nested object {"a": {"b": 1}} | A column named a.b |
| A list inside a value [1, 2] | The JSON text "[1,2]" in one cell |
| null | An empty cell |
Converting in code
In a terminal, jq handles flat arrays: jq -r '(.[0] | keys_unsorted) as $k | $k, (.[] | [.[$k[]]]) | @csv' data.json. In Python, pandas.json_normalize(data).to_csv("out.csv", index=False) flattens nested objects the same way this tool does.
