Using JSON to Exchange Data

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!


This is a companion discussion topic for the original entry at http://betterexplained.com/articles/using-json-to-exchange-data/

[…] Read more […]

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…

[…] Fonte: http://betterexplained.com/articles/using-json-to-exchange-data/ […]

Hi Simon, thanks for the tip.

JSON better explained - with examples…

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…

Can we combine this with Natural Language Processing to make, for once, a comprehensive browser?

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.

@coogan: I’m not quite sure what you mean. JSON basically a programmer-friendly way to represent data.

@Greg: Thanks for the info! I wasn’t aware of that.

[…] 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. […]

You don’t need to quote the name if it has no spaces… Eg:

var fancyFruit = {name:“pear”, color:“greenish”};

Hi Steve, thanks for the tip; I didn’t know that either :).

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.

Here’s my blog post on it if you’re interested.
http://willcode4beer.blogspot.com/2007/12/xml-to-json.html

[…] Using JSON to Exchange Data | BetterExplained (tags: json javascript Ajax) […]

[…] Using JSON to Exchange Data | BetterExplained (tags: web programming json javascript ajax web2.0) […]

“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.

Ive always been interested in JSON. Im going to use it after reading this great introduction.
Thanks

This post looks interesting, thanks.

Vasudev

Vasudev Ram
Dancing Bison Enterprises
Software consulting and training
Biz site: http://www.dancingbison.com
Blog (on software innovation): http://jugad.livejournal.com
Quick and easy PDF creation toolkit: http://www.dancingbison.com/products.html

Nice, but a bit late. I’ve ben using such a technique for quite a long time. Actualy full 10 years long - that’s a decade.

But I never thought about giving it a name. It was simply a workaround to pass new content to div’s and I’ never managed to keep it as clean routine.

Hope you do. :slight_smile:

[…] 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 […]