Thursday, November 1, 2007

JSON: Alternative Data Interchange Method

What is JSON? I can just tell you to take a hike and got to http://json.org/, but I don’t think that’s what a Blog should like, so let me quote the introduction part for you:

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

The point is, JSON lets us interchange object across different programming languages without the troublesome parsing task. JSON works by converting object to JavaScript string representation of object. The best part is that JSON is available for nearly every popular programming language. For me this is definitely a great alternative to XML, which I regularly use to exchange data on AJAX calls between client website (JavaScript) to ASP.NET or PHP server. Interestingly in JavaScript an object represented with JSON string can be “deserialized” (that is, converted back to object) by simply evaluate the string by using “eval” function. Comparison between object represented in XML dan JSON string is available at http://json.org/example.html).  

Enough said that JSON is certainly a good or at least interesting alternative for object exchange due to its simplicity.