JSON: Alternative Javascript object syntax

Published November 3rd, 2005

When I began researching the technology I’d need to build this CMS I’ve been working on — specifically, familiarising myself with some of the more esoteric aspects of Javascript — I kept coming across example code that didn’t seem to make any sense. In place of functions and arrays there would be just a bunch of curly braces, colons and commas. And seemingly no matter how hard I looked, I couldn’t find any explanation as to what this stuff actually was.

In the end it was just by decyphering the various code examples that I came to understand that Javascript has an alternative way of defining objects (and, by extension, arrays). I know I’m way behind the curve here, but I swear it came as a total revelation to me.

Anyway, I eventually discovered that it’s known as JSON (Javascript Object Notation), and I’ve found that it’s actually quite a useful shorthand when you need to pass around data for Javascript (for example, I use it to package up data generated by PHP scripts called via XMLHTTPRequest). Anyway there are plenty of resources that explain how it works (eg. here).

Get a Trackback link

1 Comments

  1. Aristotle Pagaltzis on November 4, 2005

    It’s also useful as a way to pass structured data between applications, even if no Javascript is involved. It’s easy to parse and most dynamic languages do in fact already have libraries for the task. It can often be nicer than XML for simple things.

Leave a comment

Comment Policy: First time comments are moderated. Please be patient.

OpenID

Anonymous