I was surprised he didn't mention ease of use inside JavaScript.
I was surprised he didn't mention ease of use inside JavaScript.
It may or may not be the same to parse, say, JSON and XML.
But how is
xmlDoc=new DOMParser().parseFromString(booksXml);
newatt=xmlDoc.createAttribute("edition");
newatt.nodeValue="first";
x=xmlDoc.getElementsByTagName("title");
x[0].setAttributeNode(newatt);
as easy to use as
JSON.parse(booksJson).title.edition = 'first'
?
This advantage has nothing to do with eval(), but rather that JSON is pretty much built-in everywhere nowadays.
I can just think in XML easier than remembering "Okay, so there's a bracket here, and a curly brace here, or is it curly brace and bracket? Do I need to include a key value here or not? Oh crap, I overlooked a comma again." I constantly have to send my JSON through lint, where I don't ever have to worry about that with XML.