nathanbweb
nathanbweb

Reputation: 717

Parsing a nested JSON object using 'each'

I'm using the jQuery template plugin to display JSON info from Google Books API to produce a book list here: http://jsfiddle.net/yuW6L

I can get and display basic info like the title from the JSON with the template tags

{{each items}}

and

${volumeInfo.title}

But the ISBN is nested in a portion of the JSON that looks like this:

...
"industryIdentifiers":[
                     {
                        "type":"ISBN_10",
                        "identifier":"1593374313"
                     },
                     {
                        "type":"ISBN_13",
                        "identifier":"9781593374310"
                     }

I can't display the ISBN-10 this way:

volumeInfo.industryIdentifiers.identifier[1]

I don't think I can do this:

{{each items.volumeInfo.industryIdentifiers}}
...
${identifier}

What's the way to parse and display the ISBN-10?

Upvotes: 0

Views: 3194

Answers (1)

Jesse Jashinsky
Jesse Jashinsky

Reputation: 10663

Your first try has the index at the wrong location. industryIdentifiers is the array, so place the index after that.

volumeInfo.industryIdentifiers[0].identifier

Upvotes: 1

Related Questions