Yesterday a reader asked me a question about one of my blog posts. In the blog post, I described a Cordova application that would retrieve a list of URLs from a server. It would then fetch each URL and download the resource to the device. I casually described the data as "an array of URLs in JSON" and assumed everyone would know what that meant. Of course, not everyone does know what JSON means.

It got me thinking about how someone would learn more about JSON and become more familiar with it. You can start over at for a formal definition, but I found the Wikipedia page, specifically the syntax example here, to be a bit simpler to digest.

At it's heart, JSON is a string format that can represent data. Just like XML, it can take abstract data structures and represent them in a string format that can be sent over the wire. That makes it specifically well suited for APIs. JavaScript has native support for working with it as do loads of other languages (including ColdFusion). Compared to XML, JSON is much slimmer and just as easy to read.

JSON represents simple values, like strings and numbers, just as they are, so "ray" in JSON is... "ray", and 6 is 6.

Arrays are represented by using brackets and a comma between each item: ["ray", 6, "i am not a number", "etc"]

Objects (ColdFusion folks - think structures) are represented by curly brackets. Each name/value pair is represented by name, colon, value. So: { name:"Ray", age:41, gender:"awesome"}.

Working with JSON in JavaScript is relatively trivial. If you use jQuery to make an XHR request then you can simply tell jQuery that a URL returns JSON and you've get a native JavaScript object to work with. Modern browsers also ship with support to create JSON (stringify) and read it (parse). You can read more about that at the excellent MDN docs: JSON.

Knowing the function that creates JSON, a nice way to play with it is to open your browser console and just try a few things out.


Any other suggestions? On a whim, I asked on Twitter how folks learned or were introduced to JSON. I got some fun responses (and hopefully this works, the preview doesn't show replies, but they should be showing up):