Parse JSON with jQuery and JavaScript

clipped from blog.reindel.com

While exploring the options for traversing JSON, I discovered that there is no official W3C documentation, or even a draft. As a subset of the ECMAScript language specification, it will probably remain under the governance of ECMA International.

So unlike XPath, which is a commonly accepted language for traversing XML, JSON must rely on JavaScript’s object notation. As such, some custom JavaScript will always be required (i.e. – no jQuery selectors). Some progress has been made in addressing the overarching need, but I maintain a high level of specificity in the following snippet.

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.

Related Posts:

  • No Related Posts
This entry was posted in Web Development. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *