My recent flurry of questions on Yahoo! Answers didn't have an alteriaulterior motive until about an hour ago, when I remembered Yahoo! released an API for Yahoo! Answers. The perfect API for my first foray into JSON!

The page I've created also listed as “Questions (using JSON data)” under code projects in the side nav, is a list of the questions I've asked pulled in from Yahoo! in real time. I've explained more about the technique used in the page, and it is below for reference. Suffice to say JSON is a really useful data format in the web developers arsenal, and it needs embracing much more by the web development community.

If you have any questions about JSON do ask away, and I'll do my best to answer or clarify what might not be obvious to the none Web 2.0 / AJAX developers out there.

“This is my first use of JSON. It loads the questions in from the Yahoo Answers API, specifying the output as JSON, and provides a function name for the callback. This functions is then executed, and as JSON is all JavaScript under the hood, it is instantly available as an object to add into the page's DOM as a list of questions.

For more information check out the Yahoo Developer pages, there are some security risks with using JSON the way I have from a data source you don't trust (unlike Yahoo), so read up on it first. Also take a look at the source of this page for an example of how its implemented in the real world!

All in all this was the quickest, easiest API I've ever implemented. I could have done the same thing with XML, but the fact that parsing the JSON output is so much easier, you'd be foolish not to look into it and try it out.”