- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <HTML>
- <HEAD>
- <TITLE> New Document </TITLE>
- <SCRIPTLANGUAGE="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,Qiaotou Tax Office, Sheqi County Internal Revenue Service,14113295100,d6d223892dc94f5bb501d4408a68333d,swjg_dm);>14113295100</a>','Sheqi County State Taxation Bureau Qiaotou Tax So', 'The West Section of Changjiang Road, Suburban Township, Sheqi County']]" ;
- //The JSON string can be converted to an object through the eval() function
- 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 function is the opposite of parse, used to convert a js object to JSON text.
- var jsonText = JSON.stringify(obj);
- alert(jsonText);
- // For security reasons, it is better to use a JSON parser. A JSON parser will only accept JSON text. So it is safer.
- var myObject = JSON.parse(myJSONtext, filter);
- //The optional filter parameter will traverse each value key value pair and perform related processing. Such as:
- //Such as
- myData = JSON.parse(text, function (key, value) {
- return key.indexOf('date') >= 0 ? new Date(value) : value; });
- //stringifier function is the opposite of parse, used to convert a js object to JSON text.
- var myJSONText = JSON.stringifier(myObject);
- */
- </SCRIPT>
- </HEAD>
- <BODY>
- </BODY>
- </HTML>