On Monday, 30 November 2015 at 01:02:38 UTC, Jonathan M Davis wrote:
On Monday, 30 November 2015 at 00:30:07 UTC, Chris Wright wrote:
I'm considering adding JSON5 support to std.json and want to know how well this would be received.

JSON5 is pretty much just modern JavaScript's object literal format, allowing things like comments, trailing commas, and single-quoted strings.

I only plan to add support for parsing JSON5, not emitting it. So there should be no compatibility concerns with what std.json emits.

Since it's technically a breaking change (people can use std.json currently to validate that a document is valid JSON), I am inclined to make JSON5 be off by default and add an option to parse JSON5 rather than JSON1. Anyone have strong feelings about this?

Having a JSON 5 parser makes some sense, but I don't think that it makes any sense to have one which can parse JSON 5 but not emit it. Either you're dealing with JSON 5 or you're not, and the historical approach of the internet to be lax in what you accept and strict what you emit has proven to be a horrible approach IMHO.

It's pointless to emit most of the JSON5 relaxations - I see no reason why the emitter should specifically add trailing commas, and I don't see how it can emit comments...

The only JSON5 feature that is not syntactic sugar is the special floating point values, and the current std.json halfway supports it if you use `JSONOptions.specialFloatLiterals` - http://dpaste.dzfl.pl/42bbe53e00f9. "NaN" is emitted the same as JSON5, but for infinity we emit "Infinite" while JSON5 specifies "Infinity".

Reply via email to