YAML 1.2 Ensconces and Envelopes JSON

May 23rd 13:13
by why

Hey, some progress. Three-and-a-half years after the working draft of YAML 1.1, Oren Ben-Kiki has put up a draft of YAML 1.2. The big deal here is (at last) complete compatibility with JSON.

From the new section (1.4) Relation to JSON:

YAML can therefore be viewed as a natural superset of JSON, offering improved human readability and a more complete information model. This is also the case in practice; every JSON file is also a valid YAML file. This makes it easy to migrate from JSON to YAML if/when the additional features are required.

This took some movement from the triumverate (Oren, Ingy, Clark) who govern YAML. JSON’s adoption dwarfs YAML’s. They have always been very, very close. But always cigarless. The issues have been encoding, whitespace, escape characters and the colon issue (fourth paragraph.)

Still, YAML has seen some in-roads with nods from Rails and RubyGems and App Engine. Which is surprising since YAML development has always been slow. Writing a YAML parser is pretty difficult.

Finally, these discrepancies are all ironed out. And, so, YAML 1.2 describes itself as “mostly a superset of version 1.1, defined for the purpose of ensuring JSON compatibility.” Uhh, let’s see, what else can I tell you… The name JSON appears 72 times?


Oh, and, the new YAML.org is sensational. A snapshot, in case it changes one day:

Reminiscent of the home page of Clark Evans, one of YAML’s creators. Eat whitespace, microformats! I’m really glad to see YAML.org embrace the two-space indent, though.

The odd part of the YAML.org serialization is the news section:

News:
  - 11-MAY-2008 -- Oren Ben-Kiki has released a new YAML 1.2 spec draft.
  - 29-NOV-2007 -- Alexey Zakhlestin has updated his Syck (YAML 1.0) binding for PHP

Each of these one-liner announcements is an entry in a YAML array. However, the line itself is just a string. Despite having a timestamp format and inline lists, here we’ve got an array of strings.

A nested array means no extra parser to read the dates.

News:
  - [2008-05-11, Oren Ben-Kiki has released a new YAML 1.2 spec draft.]
  - [2007-12-29, Alexey Zakhlestin has updated his Syck (YAML 1.0) binding for PHP]

And now the page is its own news feed. If you remove all the HTML tags and serve it as text/x-yaml, that is.

Now begin the comments …

3 comments

Brian

said on May 28th 21:37

Four years ago you called it!. Now, is there any practical functional relation between YAML and microformats? Is there a way to unobtrusively embed YAML in HTML maybe all wrapped up in CSS ? That would be a useful easy-reading approach for microformats. (The whitespace parsing in XML and microformats seem similar, with YAML a good bit friendlier.)

crzwdjk

said on May 28th 23:51

So is there going to be a Syck for YAML 1.2? Cause syck is totally the bee’s knees of YAML -parsing. I use it everywhere I go. Even in C++.

Merkle

said on June 5th 13:24

Neat!

Any word on if anybody’s planning to fix yaml.rb’s mishandling of option passing?

Comments are closed for this entry.