Why doesn't JSON support comments?
- Published at
- Updated at
- Reading time
- 1min
This post is a note that includes my thoughts about something I found online. Check it out yourself!
Did you ever curse the JSON data format for not allowing comments and wondered what the heck? Yeah, same here.
Surprisingly, JSON, in its initial spec, did allow comments, but comment support was removed for three reasons:
- People put parsing instructions into comments breaking portability across platforms and languages.
- Comments introduced complexity that might not be needed for a data format.
- The JSON creators wanted it to be compatible with early YAML versions.
It's a bummer because JSON outgrew its serial data use case, and it's widespread to have JSON config files these days. :/
Pawel Grzybek pointed out that the lack of comments and other features led to the JSON5 spec, which aimed to be a JSON extension suitable for config files and was adopted by VS Code and many other software products today.
If you want to learn more, here's why comments were removed on YouTube.
Was this post helpful?
Yes? Cool! You might want to check out Web Weekly for more WebDev shenanigans. The last edition went out 4 days ago.
Yes? Cool! You might want to check out Web Weekly for more WebDev shenanigans. The last edition went out 4 days ago.
Related Topics
Related Articles
- Resumability, compilers and event delegation
- How to fail function calls with undefined arguments with a one-liner (sorta)
- How to split JavaScript strings into sentences, words or graphemes with "Intl.Segmenter"
- How to find all render-blocking resources with JavaScript
- How to detect if a font is supported