4 ms·
Not really. Imagine if HTML was implemented as JSON. Consider a hyperlink: { 'a' : { 'attributes' : { 'href' : 'http://www.google.com/' }, 'v
by bradgessler 14y ago
Not really. Imagine if HTML was implemented as JSON. Consider a hyperlink:
{ 'a' :
{
'attributes' : { 'href' : 'http://www.google.com/' },
'val' : 'Google Search Engine'
}
}
That's insanity when compared to an XML format:
<a href="http://www.google.com/">Google Search Engine</a>
XML is actually a great hypermedia format. It just got a bad wrap with SOAP, WSDL, etc.
- reissbaker 14y agoA 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.