Closed prescod closed 3 years ago
Thanks for the suggestions. As mentioned in https://github.com/json5/json5/issues/3 using string prefixes is not actually backward compatible with existing JSON5 documents in a literal sense. You have provided no metrics to show that there are no JSON5 documents with string prefixes.
Also, how would one write a JSON5 document that contains a string with a prefix? You have provided no mechanism to escape a prefix.
This also has the potential to open the door for more prefixes. Why only stop at Date prefixes? Why not RegExp, Map, Set, or UInt8Array prefixes?
This proposal tries to reflect the following design principles:
JSON5 is a specification, so it is more helpful when it is unambiguous and prescriptive rather than optional
JSON5 does not have any other "recommended" encodings that I noticed. Every element is unambiguously one type or another.
String prefixes are backwards compatible with regular JSON and with every existing JSON5 parser.
The biggest virtue of JSON is that parsers decode things to native objects with minimum intervention by the programmer.
Parsers generally do not have schemas available, and therefore must determine the types of things based on the actual syntax in the payload.
ECMAScript 5 has an unambiguous format for date strings, which is compatible with both IETF standards and ISO standards, and we should use it.