JSON as a subset of YAML, closing the last caveat

Michael G Schwern <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
As most of you are probably aware, JSON is an accidental subset of YAML.
http://redhanded.hobix.com/inspect/yamlIsJson.html

This is very handy to shut down YAML vs JSON format wars.  Which should the
project accept?  Use a YAML parser and accept both!

But there's one important caveat:  The comments.  JSON comments (C++ style //
and /* */) are not valid YAML comments.  Any JSON document must first be
stripped of its comments before it can be considered YAML.  This is annoying.
 It would be very nice to hang out a "We accept JSON and YAML" shingle with no
practical caveats.  YAML can then strap itself onto JSON's popularity.

Some might say "but comments are just presentation, they don't have any effect
on the data", and while that is true they are still useful, and people write
them and it remains an obstacle to JSON/YAML interchange.

What's to be done?  I see several levels.

1) Ignore it.

2) Individual YAML parser authors hack in support for JSON comments,
   possibly with a switch to turn it on and off.

3) The YAML spec contains a suggestion that YAML parsers handle JSON
   comments complete with a suggested grammar.

4) The YAML spec be amended to accept JSON single-line comments (//) which
   are already very similar to YAML comments.

5) The YAML spec be amended to accept both JSON single and multi-line (/* */)
   comments.

Its such a small change to make YAML a complete superset of JSON, seems like
it would be worth it to take some action to close the gap.


(NOTE: to clarify I'm not saying to get rid of YAML's existing comments).


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.