Click here to Skip to main content
15,918,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am parsing the json file .I need all value of label property of commandList in an array .I am able to get all values of label .But I need only commandList label value can we get this ?

http://jsfiddle.net/62ryk/1/


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)
Posted
Updated 22-May-14 21:40pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900