<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE>
<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]); }