<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript">
var json = [
{
id : "tost",
children: [{
url:"http://www.google.com",
text: "Google",
checked: true
}, {
url:"http://www.yahoo.com",
text: "Yahoo",
checked: true
}]
},
{
id : "test",
children: [{
url:"http://www.experts-exchange.com",
text: "EE",
checked: true
}, {
url:"http://stackoverflow.com",
text: "Stack",
checked: true
}]
}
];
function getJSON(id) {
for(var i in json) if(json[i].id == id) break;
return json[i];
}
function init() {
result = getJSON("test").children;
for(var i=0;i<result.length;i++) {
alert( "children URL : " + result[i].url );
alert( "children text : " + result[i].text );
alert( "children checked : " + result[i].checked );
}
}
</script>
</head>
<body onload="init();">
</body>
</html>
|