getJSON()
will also parse the JSON for you after fetching, so from then on, you are working with a simple Javascript array ([]
marks an array in JSON). The documentation also has examples on how to handle the fetched data.
You can get all the values in an array using a for
loop:
$.getJSON("url_with_json_here", function(data){
for (var i = 0, len = data.length; i < len; i++) {
console.log(data[i]);
}
});
Check your console to see the output (Chrome, Firefox/Firebug, IE).
jQuery also provides $.each()
for iterations, so you could also do this:
$.getJSON("url_with_json_here", function(data){
$.each(data, function (index, value) {
console.log(value);
});
});