Saturday, January 06, 2007

JSON vs XML

On the fringes of the Internet, another epic battle is brewing. Its not the notorious browser war, but one on data formats. Welcome to the JSON vs XML debate.

Introduction - XML
XML like HTML or xHTML, is NOT a programming language, but a mark up language. XML stands for Extensible Markup Language and is endorsed by W3C. It is the standard for xHTML, exchanging of data in Ajax web applications, RSS feeds, and desktop applications such as FileZilla even use it as a form of data storage.

Introduction - JSON
JSON, pronounced "Jason", stands for JavaScript Object Notation, and is considered a much simpler alternative to XML. Since JSON is a subset of JavaScript's object literal notation, one can then recreate the data object with a simple eval(). If you are really new to JSON, take a peek at this.

The debate - Some main points
  • Currently, XML has the upper hand, given its history, breadth and depth of usage. It has been around for almost a decade and is widely accepted.
  • Its much easier to parse JSON and JSON parsers are usually more than 100 times faster than XML parsers.
  • Higher security concerns with JSON, such as cross-site scripting, because of the usage of the eval() function.
  • Maybe JSON is just XML simplied - just replace a change of brackets.
  • JSON is NOT XML - JSON has not namespaces, and has no validator.
  • Parsing XML is troublesome and XML is strict - a little bit of error causes a big headache. On the other hand, XML, like HTML, has a loose structure.
  • Continue to waste time arguing.... Ever since Tim Bray (XML's creator), fired the first salvo, things have been going a little out of hand.

No comments: