Martin Probst's weblog

Markups raison d'ĂȘtre

Monday, January 29, 2007, 09:30 — 0 comments Edit

David Megginson posted a follow up on his earlier take on JSON, which contains an excellent example/explanation on the advantages of markup compared to hard wired data structures.

He starts of with a simple names example and ends up with the following JSON structure, in a futile attempt to design the be-all-end-all of names data structures:

>    {"type": "name", "gender": "male", "prefix": "Don",
>      "given-name": "Alonso", "surname": "Quixote",
>      "surname-after-given-names": true, "postfix": "de la Mancha"}

Where the minimal needed markup would still be:

>    <name gender="male">Don Alonso <surname>Quixote</surname> de la Mancha</name>

Granted: the JSON code contains a lot more semantic information about it's content, and that's why it's so much more complicated. But that is exactly the point: with XML (or markup in general) you can leave your data structures underspecified like Don Quixote's name, still have meaningful semantic annotations in parts of them, and then later go on and add other information to the data. Properly written clients (i.e. that don't depend on the exact number of XML elements below name) will continue to work without noticing.

Data structures such as the JSON code above require you to actually specify all this stuff upfront, and adding to them later will break any existing clients.

Great post, go read it.

PS: Sean McGrath elaborates.


No comments.