Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] My first JSON object



Dave M G wrote:
Darren, Godwin, Simon, Fredric, TLUG,

Thank you for the advice.

I'm sold on the idea that I should use JQuery to handle all the fine print of JSON handling. However, I'm just a little fuzzy on how to use JQuery for this.

Most of the examples I've looked at on the web use an additional Javascript file called json2.js, available from json.org. This doesn't seem to be a plug in for JQuery, but a separate (?) set of code for working with JSON, but I don't quite get what it does.

Does JQuery not natively support JSON...?
For the jQuery.ajax (a.k.a. $.ajax) method you can specify dataType as "json". This will make jQuery parse the reponse as JSON. If you are serious about jQuery you need to learn to find your way around jquery.com and specifically the documentation. The learning curve is pretty steep but not that high (at least not if you know the http basics). You can find examples there too and some forums.

As far as I understand the idea behind JSON is that you send objects in form of javascript code (a subset of javascript) that, when evaluated, can be used as an object and dealt with appropriately. I have tried this technique a couple of times and while it is probably very efficient it is also reputed to have some security flaws.

I decided to go for xml and jQuery can be used as a powerful xml parser too (the same way it parses http). Parsing xml is probably less efficient but we are talking user interfaces (browsers) so a few milliseconds will not matter. I have other reasons for using xml but I think I would use xml regardless of those. I am however sure others have other preferences.

/Fredric


begin:vcard
fn:Fredric Fredricson
n:Fredricson;Fredric
org:Ln4 Solutions AB
email;internet:Fredric.Fredricson@example.com
title:CTO
tel;home:+46 8 91 64 39
tel;cell:+46 70 677 58 48
version:2.1
end:vcard


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links