Bits & Bytes #4 - JSON’s world
JSON stands for JavaScript Object Notation.
I know exactly what you are thinking - Wow! That was so insightful! Thanx! - but before you get too sarcastic, hear me out. JSON is just a mechanism used by programmers to represent things. Look at it this way - for programmers to be able to work with things, they need to be able to describe them in a fairly standardized format. As an example, there are a couple of different ways my car can be described:
Verbal Style
its blue, has a few dents on the hood, and is a Ford Pinto. Oh yeah!, its got three wheels (i lost the fourth one on the freeway), and custom shag interiors. I think they were cream, but they're kinda dirty, y'know, but I think thats the color they were when I bought the car in '77.
Classifieds Style
1977 Ford Pinto, Blue with custom cream Shag Interior, Needs work. Interesting trades considered.
If you set aside the fact that we are talking about an '77 Ford Pinto, which hasn't exploded yet, there is nothing inherently wrong with the above. That said, they are not exactly the most computer-readable formats out there. To make it more computer readable, we need to put it in a more standardized format, something that a computer program can look at and say "Oh yeah, I see what all the items are!".
Take the following in eXtensible Markup Language (XML)
<car>
<year>1980</year>
<color>blue</color>
<interior>custom cream shag</interior>
</car>
Much more standardized, eh? Mind you, and I really do need to point this out, you should not fall into a semantic trap, i.e. the belief that the above tags (<car>, <year>, etc.) actually have any meaning over and above the fact that they are tags. What they mean is - really - what you want them to mean, no more, and no less. Eric Browne in The Myth of Self-Describing XML describes this much better than I can, but the bottom line is that the above could just as easily have been written as
<foo>
<bar>1980</bar>
<baz>blue</baz>
<fnord>custom cream shag</fnord>
</foo>
foo and bar are just tags, markers that are used to assign meaning to the contents, if the program that is processing the data cares to do so!
from the above XML, it is one small step to JSON. Just take the above, and re-write it as
{
"car" : {
"year" : 1980,
"color" : "blue",
"interior" : "custom cream shag"
}
}
True, the JSON and the XML are, essentially, equivalent descriptions, but the JSON has the advantage of actually being valid, and viable Javascript!. So, if the Javascript on your web-page hits a remote URL, and gets something that looks like the above JSON, it can incorporate the data immediately, without additional processing (lets leave aside the issues of security, data analysis, etc. We're trying to keep this simple here!). We can now do all sorts of fun AJAX-y stuff, cross-domain scripting, oh, you name it.
And now for the piece-de-resistance. Remember a previous edition of Bits and Bytes where we discussed data storage, and our particular variant called CouchDB? Well, CouchDB documents (think of a document as the equivalent of a row in a conventional SQL database) are actually JSON objects! Furthermore, when we were referring to STOMP in this article, the data that we send back on forth between our Application, and our Internal Systems is in JSON format! JSON is, in fact, the lingua franca of the Aptela ecosystem.
And you thought that I would never actually get around to connecting the dots between CouchDB, STOMP, and Aptela the Application. Mind you, we still have a ways to go before we can put all the pieces of the puzzle together. Stay tuned...
About the Author
Mahesh Paolini-Subramanya is the Chief Technology Officer (CTO) at Aptela. Since 2001, Mr. Paolini-Subramanya has been responsible for Aptela's technical vision, development and implementation. Drawing upon 20 years of accomplishments in telecommunications, Mr. Paolini-Subramanya is a recognized thought leader in the Voice over Internet Protocol (VoIP) industry and in Cloud Computing. More from this author >




Comments
Mtn2 | Jul 26, 2010 @ 5:54 PM
thankssssssssssssssssssssss