5 Reasons Why and 5 reasons Why Not to use JSON

I personally really like JSON, but there is still some debate around the whole XML vs JSON thing. So, in the spirit of true “10 reasons to/for/why <something>”, I present to you 5 reasons Why and 5 reasons Why Not to use JSON in your web development or AJAX project!

Why

  1. JSON is Javascript Dont waste time parsing the XML: eval() lets you deserialise JSON data into objects with minimal effort or development time.
  2. JSON is lightweight JSON can house the same data as XML, but wastes less data on packaging, for example the XML declaration is wasted bandwidth to your users.
  3. JSON is simple Unlike XML, there are no corporations struggling for “control” of JSON by piling on standard upon standard. Kiss your namespace, schema, dtd, standards-compliance worries good bye.
  4. JSON is object-oriented XML is document-orientated, meaning you often carry a lot of extra cruft just to send a tiny bit of data back to the client.
  5. JSON has wide-spread support There are lightweight libraries designed to work with JSON in many languages, including C/C++/C#, Java, PHP, ASP, Perl, Python, Ruby and more!

Why Not

  1. XML has near universal support JSON is gaining ground, but XML is still number one when it comes to support from both programming languages and development tools themselves.
  2. XML lets you package anything Using CDATA, you can send pretty much anything with XML; JSON only allows for text-data.
  3. XML’s Schemas/DTD gives you control You can enforce compliance for data entering your software by validating it against a schema first.
  4. XML is extensible JSON is great for just serialising and deserialising objects, but XML allows greater flexibility and scope for other uses, for example XSLT.
  5. XML isn’t Javascript If the idea of having your code just happily eval() the data it gets sent freaks you out as a security issue, then parsing a XML document is for you!

Basically, both JSON and XML are platform and programming language agnostic with wide spread support. Both have their pros and cons; personally I think that JSON is better suited for AJAX style software where you are deserialising on the client, with XML is better suited for the more hands-on data shunting at the back end.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.