Javascript Object Notation (JSON) is a fancy name for a simple idea: A web page can download data stored as javascript variables. It’s caused a buzz in the tech world because JSON is much easier to load, read and manipulate compared to XML. Also, parsing large XML files can be a large performance hit – JSON gives you an object, packaged up and ready to go!
For prototype users,
var e = new Element(‘script’,
{
‘src’: url,
‘type’ : ‘text/javascript’
}
);
$$(“head”)[0].appendChild(e);
Not sure about when browsers finish loading and add the files into the dom tho, there could be significant delay before objects are loaded / added using this script method…
Javascript Object Notation (JSON) is a fancy name for a simple idea: A web page can download data stored as javascript variables. It’s caused a buzz in the tech world because JSON is much easier to load, read and manipulate compared to XML. Also, parsi…
Just a side note for these dynamic loaders: You do not need the type attribute because it is ignored when the src tag is used. The server is then relied on to give the correct mime type.
[…] December 6th, 2007 in Links I have to admit that new, exciting acronyms annoy me, especially when explaining what they mean is a chore. JSON is one of these meaningless names, even though it’s a really reasonable approach. REST is another useful, but poorly named technology. Acronyms as monikers work great if you’re knee deep in the thing, but to an outsider they’re all geek. […]
Good tips. I recently had a case to need to proxy an XML file (to get around browser security) and decided I might as well convert to JSON in the process.
There is a very good generic schema on google code.
Don’t use the download though. There are versions of the schema with bug fixes in the issues.
“You don’t need to quote the name if it has no spaces…”
Steve,
Even-though in JavaScript it is unnecessary to quote object variable names, it is part of the language spec of JSON to ALWAYS do so, so in order to be compatible with all of the JSON parsers of the various languages, it is a better idea to go ahead and quote all object variable names in JSON data.
[…] JSON to exchange data: No Comments Leave a Commenttrackback addressThere was an error with your comment, please try again. name (required)email (will not be published)(required)url […]