Reputation: 1753
I am going to create dynamic content web site with HTML5 + jQuery. Which data format is best to use for web site either XML or JSON
Thanks.
Upvotes: 1
Views: 1503
Reputation: 6500
Well:
If all you want to pass around are atomic values or lists or hashes of atomic values, JSON has many of the advantages of XML: it’s straightforwardly usable over the Internet, supports a wide variety of applications, it’s easy to write programs to process JSON, it has few optional features, it’s human-legible and reasonably clear, its design is formal and concise, JSON documents are easy to create, and it uses Unicode.
If you’re writing JavaScript in a web browser, JSON is a natural fit. The XML APIs in the browser are comparitively clumsy and the natural mapping from JavaScript objects to JSON eliminates the serialization issues that arise if you’re careless with XML.
One line of argument for JSON over XML is simplicity. If you mean it’s simpler to have a single data interchange format instead of two, that’s incontrovertibly the case. If you mean JSON is intrinsically simpler than XML, well, I’m not sure that’s so obvious. For bundles of atomic values, it’s a little simpler. And the JavaScript APIs are definitely simpler. But I’ve seen attempts to represent mixed content in JSON and simple they aren’t.
XML is more complex than necessary for Web Services. By default, XML requires you to use complex features that many Web Services do not need to be successful.
source: http://digitalbazaar.com/2010/11/22/json-vs-xml/
And I totally agree.
Upvotes: 3