javascript - get string of values of certain property from JSON -


i'm trying string of isbns google books bookshelf via api. here's attempt isn't working. (i'm trying use this snippet.)

$.getjson("https://www.googleapis.com/books/v1/users/115939388709512616120/bookshelves/1004/volumes?key=myapikey", function (data) { console.log(data);  var allisbns = [];  (i = 0; < data.items.volumeinfo.industryidentifiers[0].identifier.length; i++) { allisbns.push(data.items.volumeinfo.industryidentifiers[0].identifier[i]); }  alert(allisbns); }); 

fiddle

looking @ object logged, data.items array (of length data.totalitems seems). furthermore, industryidentifiers[0].identifier seems string, , not array. therefore think wanted loop through data.items instead.

also may worth noting should not going explicit index on industryidentifiers unless the spec calls out predefined order. recommend finding identifier type === "isbn_10":

for (var = 0; < data.items.length; i++) {     (var j = 0; j < data.items[i].volumeinfo.industryidentifiers.length; j++) {         if (data.items[i].volumeinfo.industryidentifiers[j].type === "isbn_10")                     allisbns.push(data.items[i].volumeinfo.industryidentifiers[j].identifier);     } } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -