6 ms·
I like using JSON because - There are lots of great libraries for nearly every language to parse it, or they're built in - It's got the benefits of XML (tags
by eat_veggies 9y ago
I like using JSON because
- There are lots of great libraries for nearly every language to parse it, or they're built in
- It's got the benefits of XML (tags are right next to the data, unlike CSV) while being way less typing
- It's easy to scan since I'm already used to seeing [] and {} to represent common data structures
- I can pretty print it or remove whitespace
- It's popular, meaning there are lots of tools to work with it, but it's simple enough that a text editor will do
- Most text editors will match brackets and indentation for me, so it's not a huge issue
- MichaelGG 9y agoIf it just had comments, trailing commas, and didn't require quoting names, I could forgive the brace matching. Really shortsighted.
- mercer 9y agoI don't know about the other stuff, but I sort of see why comments were not supported: https://news.ycombinator.com/item?id=3912149 https://news.ycombinator.com/item?id=3912149 Personally I do miss them tremendously though.
- captainmuon 9y agoSome implementations allow comments. There is a project called JSON5 that also allows trailing commas, and maybe omitting quotes for keys. I have some (private) libraries in C++, Python, and Nim that support those features, too. Basically it understands JavaScript object literals. If I find some time, I'll package them up and publish them. One thing I'd really like to change is to make the parser round-trippable, so it remembers all the whitespace and comments, and if you use these pseudo-json as config files, you can make programmatic changes without loosing anything.