I have mixed feelings about JSON, to be honest. I don't particularly love it as a data format for Ajax, because I don't feel it's that readable. It's arguably less verbose -- and therefore, also in theory, faster to send across the network -- than XML, but marginally so. And I don't think it's very intuitive. That said, there are a ton of people who really like JSON, and I'm not religious about what data format you use, so it's covered. In fact, I really treat it in the book as a competitor to XML (they have a boxing match, so to speak), and compare and contrast them heavily. In terms of depth of coverage, I think you'll find that once you get the basics on how JSON looks and is formatted (which is covered), it's a piece of cake. So I think most people looking for anything but the most extreme, advanced, unusual use-cases for JSON will find everything they need for JSON in the book. But then again, I'm biased :-)
Series Editor, Head First<br />Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0596102259/newinstance-20" target="_blank" rel="nofollow">Head Rush Ajax</a> and <a href="http://www.amazon.com/Head-First-Object-Oriented-Analysis-Design/dp/0596008678/ref=pd_bbs_sr_1/104-5348268-5670331?ie=UTF8&s=books&qid=1192568453&sr=8-1/newInstance-20" target="_blank" rel="nofollow">Head First OOA&D</a>
JSON is interesting and I may end up using it a lot on my own web site and some of the sites that I do pro bono for local non-profits, but I think JSON's utility in the enterprise stack is quite limited.
<a href="http://labryssystems.net/pblog/index.php" target="_blank" rel="nofollow">Javaville Gazette</a><br />Non-cooperation with evil is a duty. -- Mahatma Gandhi
I have mixed feelings about JSON, to be honest. I don't particularly love it as a data format for Ajax, because I don't feel it's that readable. It's arguably less verbose -- and therefore, also in theory, faster to send across the network -- than XML, but marginally so. And I don't think it's very intuitive.
Hello Brett, Nice to have you here in JR. Question - why is readability important becasue we extract the data and display it on the screen?
Ajax is used for handling the response from the server.
If the server response header has a content-type of "text/plain" you have to use the responseText property to retrieve the response data.
If the server response header has a content-type of "text/xml" then the XMLHttpRequest parsed XML data available through responseXML property.
If the server side service(or jsp/asp/php/cgi etc) sends a JSON response it will be in the JSON format which will have a content-type response header of "text/plain", hence it will need to be retrieved using the responseText property.
Parsing the JSON response is much easier then parsing the XML response, thats one difference between then two reponses.
Regarding sending the JSON response from the server side, there are frameworks available which can create JSON from data which can be then readily sent to the response.