[Solved] javascript and json object [closed]


Here’s how you could do it:

var json = '[{"curUrl":"acme.com", "nextUrl":"acme2.com", "relation":"none"},{"curUrl":"acme3.com", "nextUrl":"acme4.com", "relation":"none"},{"curUrl":"acme5.com", "nextUrl":"acme6.com", "relation":"none"}]';

var arrCurUrls = new Array();

function getCurUrls(){
    var parsedJSON = JSON.parse(json);

    for(var i=0; i<parsedJSON.length; i++){
        arrCurUrls.push(parsedJSON[i]['curUrl']);
    }
    alert(arrCurUrls);
}

solved javascript and json object [closed]