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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -