JSON/jQuery

this is a follow-up on my previous JSON post:

now I’m trying to pull from this JSON with jQuery; my example is here:
http://mayacove.com/dev/json/rockbands.html
not working… obviously it’s more complex than the JSON in jQuery example here:

http://api.jquery.com/jQuery.getJSON/

how do I pull from a more complex JSON than the example @ jQuery site? I wish they had examples with more complex JSON’s…

obviously I need to be more specific about WHICH key and WHICH values, since there is more than one level…
is there a ref. somewhere of all the methods/properties to pull from JSON’s???
(what is there apart from “key” and “val”?) are “key” and “val” JSON properties? or just plain Javascript from the array? because array is just a list, you don’t have “key” and “value” in an array, right?

also “item”… that’s a jQuery JSON property? it’s very vague… an item consists of a key/value pair?

I really need a reference for all this…

thank you…

(font in this editing window is still TOO SMALL, if I make it bigger, I DON’T SEE IT BIGGER, it should like in jQuery forum, you make font bigger while you’re editing, you SEE it bigger…)

JSON just gets turned into native arrays / hashes when it’s called with getJSON.
The jquery each method is just an iterator over arrays / hashes


[
    {
        "Name": "Beatles",
        "Country": "England",
        "YearFormed": 1959,
        "Style": "Rock'n'Roll",
        "Members": [
            "Paul",
            "John",
            "George",
            "Ringo"
        ]
    },
    {
        "Name": "Rolling Stones",
        "Country": "England",
        "YearFormed": 1959,
        "Style": "Rock'n'Roll",
        "Members": [
            "Paul",
            "John",
            "George",
            "Ringo"
        ]
    }
]

Give the variables good names so you know what you are iterating over.


$.getJSON('json/rockbands.json', function(bands) {

  $.each(bands, function(band) {
    console.log(band.Name)
    $.each(band.Members, function(member) {
      console.log(member);
    }
  });

});

thank you very much…

oh brother… I’m getting an error in CORE jQuery now… (1.4)

a is undefined... 

WTF???

http://mayacove.com/dev/json/rockbands.html

thank you…

PS: getting same error in 1.7…

???