When you work with data on the modern web, you mostly likely work with JSON. Almost every web service offers a data stream in JSON, which has significant advantages over its predecessor, XML. With JSON, a simple
Recursively named YAML Ain’t Markup Language, YAML is a superset of JSON. This means that any valid JSON is also valid YAML, and an app that expects YAML can consume JSON without missing a beat. However, YAML supports features that JSON doesn’t, such as comments, so valid YAML can’t be used interchangeably with JSON.
One of the biggest differences between YAML and JSON — and one of the driving forces behind the creation of YAML — is that YAML is designed to be human readable. To achieve this, in addition to supporting comments, the language treats white space as significant. For instance, indenting multiple lines of data implicitly marks those lines as a block. Other aspects of the language enable you to encode data objects such as arrays without the enclosing and delimiting characters used in JSON. In fact, if you’ve ever worked with Markdown, YAML should look very familiar, as both YAML and Markdown have quite a bit of syntax in common.
Check out my recently released course, Processing and Interchanging JSON Data on Lynda.com (subscription required), for more about working with JSON, including converting between JSON and YAML and between JSON and XML.