I have the following json object and I would like to read it (access some data from it)
how can I do it in Javascript please ?
var allSites =
{"oldSites":
[
{
"site0" : "http://site0.com/",
"site1" : "http://site1.com/",
"site2" : "http://site2.com/"
}
],
"newSites":
[
{
"site0" : "http://site0/new",
"site1" : "http://site1/new",
"site2" : "http://site2/new"
}
]
};
This is what I did but I get undefined.
var allSites = eval(allSites);
alert(allSites.oldSites.site0);
Thanks.
evaling the object(and anyway with a JSON string you should useJSON.parse)