Until now, I've just considered JSON to be the equivalent to regular JavaScript object literal notation. Jonathan Snook has now explained the difference. It turns out JSON is a bit more picky than regular object literals. Key names must be quoted, and you can only use double-quotes around keys and values. Also, functions are not allowed as values.
I gave an example of JSON some time ago that turns out to be wrong. I used single-quotes in my JSON example. I'll leave them there since the example works, but I just can't call it JSON.
If you're doing JSON-style coding by hand for your Ajax communications, you can get away with using any object literals. So why care if it fits the JSON standard? Well, there are parsers and tools out there which can work with the JSON format, and if you don't fit the standard, they might not work.
I have no idea why the designers of JSON didn't just make the standard flexible enough to handle single quotes and unquoted keys. It's also confusing that JSON stands for JavaScript Object Notation, and that Object Notation somehow means something different from the object literal notation in JavaScript. Great.
Moral of the story: it probably doesn't matter if you use the JSON standard until you have to interoperate with JSON tools or feel the need to offer your JSON data to the public. You should probably stop calling it JSON if you use single-quotes, though.
Just to clarify a couple things that even confused me about JSON. Despite calling it "object notation", the ECMA spec never uses the term. The object literal is the term the spec uses. Hey, I've used the term object notation, too, as the equivilant of object literal.
That issue aside, the reason for double quotes and not single quotes likely has to do with language support. For example, valid JSON is valid JavaScript is valid Python. In most other languages, double quotes are used to denote strings. There's a definite consistency in sticking with double quotes.
Yeah, the language support thing makes sense now. The "object notation" thing threw me off too even as I was writing this article - I added the word "literal" afterwards because I wasn't even aware I should be using the word.
Also, suppose you have a JSON string in PHP or some other language, and you want to put the string as the value in an HTML form element. When constructing the (x)HTML and the value attribute of the input tag, do you single-quote the JSON? Do you double-quote it? Do you know in advance whether the string you are about to put between quotes has it's own internal quotes which will make for broken HTML?
Having "double quoted only" is very wise because then nobody has to constantly guess or convert, and you can print the JSON string into the HTML and reliably use single quotes around it.
@Terr - That's actually rather dangerous. You should be using addslashes() or a similar function to escape single quotes when placing a JSON string inside single quotes.
Consider the following valid JSON example:
var json = '{ "key": "this's the value" }';
As you can see, the single quote inside the string will cause a syntax error.