NSA: Please Turn off the Lights When You Leave. Nothing to See Here.

Linux Advocate Dietrich Schmitz shows how the general public can take action to truly protect their privacy using GnuPG with Evolution email. Read the details.

Mailvelope for Chrome: PGP Encrypted Email Made Easy

Linux Advocate Dietrich Schmitz officially endorses what he deems is a truly secure, easy to use PGP email encryption program. Read the details.

Step off Microsoft's License Treadmill to FOSS Linux

Linux Advocate Dietrich Schmitz reminds CIOs that XP Desktops destined for MS end of life support can be reprovisioned with FOSS Linux to run like brand new. Read how.

Bitcoin is NOT Money -- it's a Commodity

Linux Advocate shares news that the U.S. Treasury will treat Bitcoin as a Commodity 'Investment'. Read the details.

Google Drive Gets a Failing Grade on Privacy Protection

Linux Advocate Dietrich Schmitz puts out a public service privacy warning. Google Drive gets a failing grade on protecting your privacy.

Email: A Fundamentally Broken System

Email needs an overhaul. Privacy must be integrated.

Opinion

Cookie Cutter Distros Don't Cut It

Opinion

The 'Linux Inside' Stigma - It's real and it's a problem.

U.S. Patent and Trademark Office Turn a Deaf Ear

Linux Advocate Dietrich Schmitz reminds readers of a long ago failed petition by Mathematician Prof. Donald Knuth for stopping issuance of Software Patents.

Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Saturday, March 23, 2013

JSON: The Undisputed King of Web Interchange APIs

by +Dietrich Schmitz

I have been roaming over the InterTubes in search of various technical information as regards this website.

It can at times be like looking for a 'needle in a haystack' when it comes to pinning down a specific method of getting your website to function in a specific way.

Like for instance, it occurred to me that there ought to be a 'standard way' to query (via some application programming interface or API call) a chunk of information concerning activity taken on the website, be it global website metadata, something about a post or collection of posts or about a specific author--stuff like that. (Credit image right: www.json.org)

Well, the bad news is, there really isn't one 'standard' way.  The good news is, today at least, you have more than one way to obtain that information at your disposal.  But that can create confusion.

In fact, if you do the requisite research as I have (in an effort to answer a few needs here on Linux Advocates), you might at first be overwhelmed by the sheer surplus of data, help websites, how-to's, 'know-it-all' posts that confront you, all bombarding your brain on a Google search adventure.

Fortunately, in the case of Blogger, the documentation for their web application programming interface is right at your fingertips here.

The methods you ultimately choose for reaching into your website's data cache will depend on which web engine you have chosen and which tools you employ.

So began my journey into the wonderful world of Javascript Object Notation, otherwise known as JSON.

For many website platforms, it might seem most direct to simply write a SQL to obtain the data needed on the backend database, used to store persistent data.  And on many websites, that is frequently done.

As for Blogger, the web monkey (Me) doesn't have access to a database per se.  The database, if there is one, isn't surfaced by Google.  Instead, what they expose is the aforementioned API, JSON.  A seemingly circuitous path, set of gymnastics a code monkey must contort into to get at the needed data.

Some things come more easily for dedicated programmers than the less initiated.  For starters, having a higher threshold of 'pain' works to one's advantage--when I can't find an answer, I obsess for days, gnash teeth, fidget, until I hit on the answer--pretty routine masochistic self-imposed torture.  Most programmers accept this as part of their occupation and resign themselves to pouring over on-line technical documentation, some better and some less so, all in a vengeful determined effort to divine the 'magic' to getting from point A (the problem) to point B (the solution)--returning the correct piece of data or desired function (behavior), hopefully.

So, after many starts and stops, interruptions, staring for long periods of time, ranging across the Internet (one time there was a sign 'You have reached the end of the Internet--turn around and go back'), I was finally feeling like I had decoded the 'Rosetta Stone' and came up with a subset of code which might be your 'prototypical' example for querying the JSON API:










Good Code Monkey.  Now press the button and take the pellet.  There.

Pretty much the above JSON code lives neatly inside of Javascript and co-exists nicely all wrapped up in a tidy HTML page.  One can also use just about any programming language under the Sun--there's most likely a library which encapsulates JSON for your preferred programming tool, be it PHP, Perl, Python, what have you.

Along the way, in my various readings, I came across this sterling article which summarizes quite well why JSON is revolutionizing the 'Internet of Things'.  The author Luc Perkins keenly observes:

"...Ten years ago, XML was the primary data interchange format. When it came on the scene, it was a breath of fresh air and a vast improvement over the truly appalling SGML (Standard Generalized Markup Language). It enabled people to do previously unthinkable things, like exchange Microsoft Office documents across HTTP connections. With all the dissatisfaction surrounding XML, it’s easy to forget just how crucial it was in the evolution of the web in its capacity as a “Swiss Army Knife of the internet.”

But it’s no secret that in the last few years, a bold transformation has been afoot in the world of data interchange. The more lightweight, bandwidth-non-intensive JSON (JavaScript Object Notation) has emerged not just as an alternative to XML, but rather as a potential full-blown successor. A variety of historical forces are now converging and conspiring to render XML less and less relevant and to crown JSON as the privileged data format of the global digital architecture of the future. I think that the only question is how near that future is.

I strongly believe that this transformation can be attributed to four broad trends, which I’ll discuss in turn:

1. APIs (application programming interfaces)
2. Big Data
3. The Internet of Things
4. Full-stack JavaScript..."

So, during my journey learning JSON, I have reached the conclusion that in today's 'mash-up' Web 2.0 world where one website incorporates chunks of data from another unbeknownst to the average user, behind the scenes is most likely JSON at work.

Ten years ago, XML might have been the only solution for serializing and exchanging data over http.
Even more sophisticated today is using JSON over Websockets which is only beginning to turn up in some of the more advanced website coding practices.

JSON's lightweight nature requires far less effort than XML and integrates into most website frameworks now as a plugin architecture if not present in its default installation.


So, does this fit with your view on the 'Internet of Things' and experience with the newest programming paradigms?  Please give your feedback!

-- Dietrich


END
Enhanced by Zemanta