[conspire] YAML, JSON, XML, oh my

Deirdre Saoirse Moen deirdre at deirdre.net
Thu Jan 9 16:05:48 PST 2020

Rick and I got into a discussion of these three different markup formats over the last few days (due to my post on the list mentioning it, and I thought I’d mention something I’d learned recently.

I was at Silicon Valley Code Camp and went to this talk on the history of JSON: https://www.youtube.com/watch?v=xZdNGfFh5BY <https://www.youtube.com/watch?v=xZdNGfFh5BY>

Douglas Crockford, the JSON codifier, pointed out that XML had essentially vanished in all but legacy enterprise applications. And it’s true, I haven’t seen it mentioned on job listings in years. Only JSON.

In terms of simplicity, YAML > JSON > XML.

What’s interesting is that, despite YAML being a simpler format, as of YAML 1.2, all JSON files are also YAML-compliant. (The reverse is not true.)

I got introduced to YAML with Ruby on Rails and got really into it. You could specify test data like:

  id: 1
  name: Forest Keeper
  speed:  88
  id: 2
  name: Ghost
  speed:  101
  id: 3
  name: Horned Frog
  speed:  100

(Note that YAML uses whitespace and indentation as syntactically significant. The names of each record are only used for test purposes and not stored in the db.)

In JSON, this would be:

  {"id": 1,
  "name": "Forest Keeper",
  "speed":  88},
  {"id": 2,
  "name": "Ghost",
  "speed":  101},
  {"id": 3,
  "name": "Horned Frog",
  "speed":  100}

Too much shifting and unshifting for those quotes and braces, imho, but usable enough.

XML would be even more verbose and I’m not even gonna go there. It’s a new decade after all.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://linuxmafia.com/pipermail/conspire/attachments/20200109/e43208b2/attachment.html>

More information about the conspire mailing list