outaTiME

at devel days

Ajaxian Featured Tutorial: Parse JSON with jQuery and JavaScript

leave a comment »

Last week, we posted a tutorial by Brian Reindel which showed how to parse XML with jQuery. The feedback was pretty good but many readers felt that JSON is the data packet format of choice and an XML-focused tutorial wasn’t their cup of tea. Brian promised a follow-up tutorial focusing on JSON and he has delivered.

In his tutorial, Parse JSON with jQuery and JavaScript, Brian takes you step-by-step through the process of retrieving and parsing a JSON packet:

Getting JSON using jQuery is extremely straightforward. Just like $.ajax(), there is a $.getJSON() method, with a call to a file, and a function to pass the data through for parsing. The common $.each() method in jQuery can be used to traverse the “nodes” (keys) that you indicate. You could just as easily use your own for loop.

As usual, Brian includes plenty of code examples to further reinforce his techniques and provides a source code download for you to review.

You can catch both tutorials here:

jQuery and XML revisited
Parse JSON with jQuery and JavaScript

(Via Ajaxian.)

Written by outaTiME

October 2, 2007 at 2:42 pm

Posted in Ajax, Development

Leave a Reply