function recursiveIteration(object, callback) { for (var property in object) { if (object.hasOwnProperty(property)) { if (typeof object[property] == "object"){ recursiveIteration(object[property], callback); }else{ //found a property which is not an object, check for your conditions here callback(object, property); } } } } var labels=new Array(); function test_cb(object, property){ if(property == "label" && object[property]) { labels.push(object[property]) } } recursiveIteration(json, test_cb); alert(labels)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)