4 ms·
JSON5 is better than JSON on my points, but it has downsides compared to YAML. For example, YAML is very good at multiline strings that don't require any sort o
by atombender 6y ago
JSON5 is better than JSON on my points, but it has downsides compared to YAML. For example, YAML is very good at multiline strings that don't require any sort of quoting, and knows to remove preceding indentation:
foo: |
"This is a string that goes across
multiple lines," he wrote.
In JSON5, you'd have to write:
{
foo: \"This is a string that goes across \
multiple lines,\" he wrote."
}
This sort of ergonomic approach is why YAML is so well-liked, I think. (Granted, YAML's use of obscure Perl-like sigils to indicate whitespace mode is annoying, but it does cover a lot of situations.)
YAML is also great at arrays, mimicking how you'd write a list in plaintext:
foo:
- "hello"
- 42
- true