JSON is a beautiful format for storing objects as human readable text. It’s succeeded where XML has failed. Not only is it not shit, it’s actually quite good! But don’t just take my word for it, have a look at some of the “cool” ways you can generate and consume JSON.
Someone on StackOverflow reckons Internet Explorer 8, Firefox 3.5+, Safari 4+, Chrome, and Opera 10+ support native JSON parsing. Douglas Crockford’s json2.js library adds the standard JSON methods to browsers that lack them. jQuery’s JSON parser makes use of the browsers native implementation where this is one.
Enough yakking, time for a demo
1 2 3 4 5 6 7 8 9 10 11 12
jQuery support for JSON
Open Firefox to any webpage that loads jQuery (e.g. jquery.com) and paste this into your Firebug console.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1 2 3 4 5 6 7 8 9 10
jQuery picks a random name for the callback to make things easier for you. In fact it does a pretty good job of hiding the inner workings of JSONP from you.
Posts in this series: