My personal opinion on what nice JSON looks like:
- Scalars as per normal
- Empty objects/arrays as
{}
or[]
- Single-entry objects on a single line if value is single-line
- Single-entry arrays are just wrapped in
[...]
(even if value is not single-line) - Arrays <= 5 items on a single line if all values are single-line
JSON.stringify()
style indenting otherwise
Indenting customisable, but defaults to tabs - I code in proportional font, so four-space looks a bit narrow, and two-space just looks ridiculous.