<SCRIPT LANGUAGE="JavaScript">
var t="{'firstName': 'cyra', 'lastName': 'richardson', 'address': {
'streetAddress': '1 Microsoft way', 'city': 'Redmond', 'state': 'WA',
'postalCode': 98052 },'phoneNumbers': [ '425-777-7777','206-777-7777' ]
}";
var jsonobj=eval('('+t+')');
alert(jsonobj.firstName);
alert(jsonobj.lastName);
var t2="[{name:'zhangsan',age:'24'},{name:'lisi',age:'30'},{name:'wangwu',age:'16'},{name:'tianqi',age:'7'}] ";
var myobj=eval(t2);
for(var i=0;i<myobj.length;i++){
alert(myobj[i].name);
alert(myobj[i].age);
}
var t3="[['<a href=#
onclick=openLink(14113295100,ÉçÆìÏعúË°¾ÖÇÅÍ·Ë°Îñ
Ëù,14113295100,d6d223892dc94f5bb501d4408a68333d,swjg_dm);>14113295100</a>','
ÉçÆìÏعúË°¾ÖÇÅÍ·Ë°ÎñËù','ÉçÆìÏسǽ¼Ï糤½Â·Î÷¶Î']]";
//ͨ¹ýeval() º¯Êý¿ÉÒÔ½«JSON×Ö·û´®×ª»¯Îª¶ÔÏó
var obj = eval(t3);
for(var i=0;i<obj.length;i++){
for(var j=0;j<obj[i].length;j++){
alert(obj[i][j]);
}
}
/*
//stringifier º¯ÊýµÄ×÷Óøú parse Ïà·´£¬ ÓÃÀ´½«Ò»¸öjs¶ÔÏóת»»Îª JSON Îı¾¡£
var jsonText = JSON.stringify(obj);
alert(jsonText);
//Èç¹û»ùÓÚ°²È«µÄ¿¼ÂǵĻ°£¬×îºÃÊÇʹÓÃÒ»¸ö JSON ½âÎöÆ÷¡£ Ò»¸ö JSON ½âÎöÆ÷½«Ö»½ÓÊÜ JSON Îı¾¡£ËùÒÔÊǸü°²È«µÄ¡£
var myObject = JSON.parse(myJSONtext, filter);
//¿ÉÑ¡µÄ filter ²ÎÊý½«±éÀúÿһ¸övalue key Öµ¶Ô£¬ ²¢½øÐÐÏà¹ØµÄ´¦Àí¡£È磺
//Èç
myData = JSON.parse(text, function (key, value) {
return key.indexOf('date') >= 0 ? new Date(value) : value; });
//stringifier º¯ÊýµÄ×÷Óøú parse Ïà·´£¬ ÓÃÀ´½«Ò»¸öjs¶ÔÏóת»»Îª JSON Îı¾¡£
var myJSONText = JSON.stringifier(myObject);
*/
</SCRIPT>
¡¡