nathanbweb
nathanbweb

Reputation: 717

Parsing a JSON object from Google Books

I'm trying to generate a book list like this:

https://google-developers.appspot.com/books/examples/viewability-with-callback

from a JSON object using Google's API for Google Books.

I've only used JSON with YQL before, and I've parsed the results like this:

$.each(data.query.results.row, function (i, item) {

as I did here http://jsfiddle.net/nathanbweb/U2QWY/4/

but with Google Books, the JSON object contains unique ISBNs as objects, so I can't parse them the same way:

$.each(data.ProcessGBSBookInfo.[[uniqueisbn]], function (i, item) {

How can I do this? My fiddle is here: http://jsfiddle.net/5tWQh/

Upvotes: 1

Views: 1475

Answers (1)

Kevin B
Kevin B

Reputation: 95027

Here's your fiddle updated to work properly: http://jsfiddle.net/5tWQh/1/

I changed your url to allow for proper JSONP callback handling, and then modified the $.each to have it iterate through the returned isbn numbers.

$.getJSON('http://books.google.com/books?jscmd=viewapi&bibkeys=0596000278,00-invalid-isbn,ISBN0765304368,0439554934&callback=??', function(data) {
...
$.each(data, function(i, item) {...

Upvotes: 2

Related Questions