3 ms·
A JSON link format more similar to the given XML would probably be: { 'tag': 'a', 'href': 'http://www.google.com', 'val': 'Google Search
by reissbaker 14y ago
A JSON link format more similar to the given XML would probably be:
{
'tag': 'a',
'href': 'http://www.google.com',
'val': 'Google Search Engine'
}
But you're right — if HTML had been based on JSON it would've been a nightmare to write. JSON is a great general-purpose format, but XML beats it out for constructing hypermedia. Not in all cases, though; compare the following:
['Peter', 'Paul', 'Mary']
<ul>
<li>Peter</li>
<li>Paul</li>
<li>Mary</li>
</ul>
So basically, it just depends on what kind of data you're transmitting. :)
- bradgessler 14y agoThe ul > li example would quickly become a nightmare if you had to specify a CSS class or start nesting content in an li.