5 ms·
I love the trailing commas for function calls. Wish we could get trailing commas for all of JSON too!
by a13n 9y ago
I love the trailing commas for function calls. Wish we could get trailing commas for all of JSON too!
- pas 9y agoFor that you'd need to wait until all major parser libraries support it, aaand that all deployments get updated. That means that little change is an at least 10 year long project.
- bfred_it 9y agoIt's called JSON5 and it also has comments. The standard JSON will never "change"
- deleted 9y ago[deleted]
- ballenf 9y agoWhy? I just don't find myself doing too much JSON manual editing. A few config files and such. Occasional editing of a server response or call for testing. I'm basing this on the assumption that the desire for trailing commas is making editing easier and reducing noise in diffs. Just curious if there are niches where people are spending a lot of time manually editing JSON or if the use case is something else entirely. I love them in code, despite initial resistance.
- azernik 9y agoThe use case for me is JSON blobs (mostly configuration files like package.json) that are checked into version control. Same motivations - reducing line-oriented diff noise.
- WalterSear 9y agoWhat I want are leading commas. Much tidier and one small thing you wouldn't have to edit/think about when adding and removing list items.
- mstade 9y agoBetter yet: automatic comma insertion! (I'm only half joking.)
- thekaleb 9y agoUnless you need to add something to the beginning.
- WalterSear 9y agoI prefer comma first notation. const hello = { , 'one' , 'two' , 'three } would be easier to visually parse than: const hello = { 'one', 'two', 'three', } Since the commas actually work as a guide.
- sAbakumoff 9y agoI suspect that they borrowed this idea from Golang's "composite literal" spec. which is really nice feature https://dave.cheney.net/2014/10/04/that-trailing-comm https://dave.cheney.net/2014/10/04/that-trailing-comm
- fanf2 9y agoTrailing commas have been allowed in C composite literals since the dawn of time.