Why JSON5? (was: Hash style comments)

# Mark S. Miller (12 years ago)

On Wed, Aug 8, 2012 at 8:58 AM, Trans <transfire at gmail.com> wrote:

[...] Now there is consideration of JSON5 (aseemk/json5). JSON5 adds support for comments, [...]

JSON: pros: standard, language neutral, extremely widely adopted, supported efficiently starting with ES5 cons: lack of comments. Need to quote property names

JSON5: pros: superset of JSON, subset of ES5, comments, no need to quote property names cons: JS specific (rather than language neutral), non-standard, needs custom parser in JS for processing on JS

SES: pros: superset of JSON, subset of ES5, includes virtually all of ES5, including of course JSON5, supported efficiently starting with ES5 with no need for a custom parser, de facto standard, already some adoption at scale (Google Sites, Google App Script) cons: JS specific (rather than language neutral), not (yet) a de jure standard

As safe midpoints between JSON and full ES5, SES has clear advantages over JSON5 and includes JSON5 as a subset. What advantages does JSON5 have over SES? Is there any use case better addressed by JSON5 than by SES?

# Kevin Reid (12 years ago)

On Fri, Aug 10, 2012 at 12:00 PM, Mark S. Miller <erights at google.com> wrote: SES:

pros: superset of JSON, subset of ES5, includes virtually all of ES5, including of course JSON5, supported efficiently starting with ES5 with no need for a custom parser, de facto standard, already some adoption at scale (Google Sites, Google App Script) cons: JS specific (rather than language neutral), not (yet) a de jure standard

As safe midpoints between JSON and full ES5, SES has clear advantages over JSON5 and includes JSON5 as a subset. What advantages does JSON5 have over SES? Is there any use case better addressed by JSON5 than by SES?

Loading JSON or JSON5 takes space and time linear in the input size; SES is unbounded. Therefore SES is significantly less safe for naïve server-side processing.