JavaScript Object Notation, or JSON, has recently flared into the public consciousness because of one simple fact: it can be used to overcome one of the limitations of Ajax, today's other hot buzzword. Ajax, which relies on HTTP connections from the browser to dynamically update pages without reloading the page, can only make that connection to the server on which the page resides, which makes it difficult to dynamically request, say, a set of results from Yahoo! Web Services.
JSON solves this problem. Because it provides a way for you to directly create an object in your script dynamically using a script tag, you can use it to, say, add a set of Yahoo data to your page.
Don't forget to check out the "Introduction to JSON" article I've got listed below for the full scoop, including that Yahoo! hack.
Your opinion matters
What is JSON, anyway?
stuffedAnimal.name = "Fluffy";
stuffedAnimal.breed = "Monster";
stuffedAnimal.legs.type = "rubbery";
stuffedAnimal.legs.number = 2;
stuffedAnimal.arms.type = "strong";
stuffedAnimal.arms.number = 5;
stuffedAnimal.texture = "soft";
That's pretty typical Javascript code; I could represent that in JSON as:
{"stuffedAnimal": {"name":"Fluffy",
"breed":"Monster",
"legs": {
"type":"rubbery",
"number":2},
"arms": {
"type":"strong",
"number":5},
"texture":"soft"}
}
Now, the ability to do that may not seem like much, but it enables you to do two very important things. First, you can dynamically create an object by manipulating the text that represents it, but that's not something most people do. The real key is that it enables you to retreive an object using web services.
And that IS a big deal.
JSON Implementations
Making it work
- The "official" JSON page
- This is the canonical information page for JSON. It includes a brief description of the actual format, but is most useful for its links to JSON toolkits in just about every programming language under the sun.
- JSON for OpenLaszlo
- Apparently OpenLaszlo's implementation of JavaScript has some issues that prevent it from working with JSON Javascript. But never fear, an implementation is here.
- sql2json() - Converts SQL Results to JSON String
- From the description: "sql2json() converts the result of the given SQL query to its equivalent JSON string. This function will take a SQL query as it argument, execute it, fetch its result and convert it to a JSON string and then return the JSON string."
Get more information on JSON
- Introducing JSON
- Also listed above, this is the canonical information page for JSON.
- Introduction to JSON
- This is the article I referred to in the introduction. It explains what JSON is, how to use it in the browser, and specifically how to use it with a dynamically added <script> tag to add Yahoo data to your page.
- Using JSON with Yahoo! Web Services
- Several web APIs will return JSON data instead of XML (or in addition to it) but the biggie at this moment is Yahoo! Web Services. This page details how that works.
- Using JSON with del.icio.us
- Del.icio.us also provides a JSON interface for their web services API. This page is the documentation for that capability.
- Project: Javascript Timetracker -- JSON and PHP
- This is the first installment of a series of articles describing a Javascript Timetracker that uses JSON to send data back and forth to a PHP page. This article shows you how the PHP part works with JSON.
What Del.icio.us says about JSON
Here are some links tagged as JSON in Del.icio.us.
- JSON
- addSizes.js: Snazzy automatic link file-size generation | Natalie Downe
- JSONLint - The JSON Validator.
- InfoQ: Your First Cup of Web 2.0 - A Quick Look at jQuery, Spring MVC, and XStream/Jettison
- Apache CouchDB: The CouchDB Project
- JSON Viewer
- IEBlog : Native JSON in IE8
- Comet Daily " Blog Archive " REST Channels: HTTP Channels with JSON support
- Mastering JSON ( JavaScript Object Notation )
- PURE Unobtrusive Rendering Engine for HTML
Blog postings about JSON
The Technorati JSON tag
One good way to keep up with a topic -- especially a new one, like JSON -- is to see what other people are saying about it. Here are the last six postings that have been tagged as "JSON", according to Technorati.
Fetching RSS feed... please stand byBooks with information on JSON
JavaScript: The Definitive Guide
Amazon Price: $29.67 (as of 10/07/2008)
List Price: $44.95
Usually ships in 24 hours
Professional Ajax, 2nd Edition (Programmer to Programmer)
Amazon Price: $26.39 (as of 10/07/2008)
List Price: $39.99
Usually ships in 24 hours
Prototype and Scriptaculous in Action [Ajax]
Amazon Price: $29.69 (as of 10/07/2008)
List Price: $44.99
Usually ships in 24 hours
Ajax for Web Application Developers (Developer's Library)
Amazon Price: $24.85 (as of 10/07/2008)
List Price: $34.99
Usually ships in 24 hours
Ajax: The Definitive Guide
Amazon Price: $31.49 (as of 10/07/2008)
List Price: $49.99
Usually ships in 24 hours
