WEB开发网
开发学院网页设计JavaScript JSON进阶(一) 阅读

JSON进阶(一)

 2010-09-14 13:44:19 来源:WEB开发网   
核心提示: 二、 Json对象--字符串1 <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>2 <!DOCTYPE HTML PUBLIC

二、 Json对象--字符串

 1 <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 3 <html>
 4     <head>
 5         <title>My JSP '1.jsp' starting page</title>
 6         <script type="text/javascript" src="js/json.js"></script>
 7     </head>
 8     <body>
 9         <script type="text/javascript">
10  function test()  
11   {   
12         var myJSONtext =   
13         {     
14             "bindings":   
15             [     
16                 {"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},     
17                 {"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},     
18                 {"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}     
19             ]     
20         };     
21         var myObject = eval(myJSONtext);     
22         alert("对象长度:"+myObject.bindings.length);     
23         for(var i=0;i<myObject.bindings.length;i++){     
24             alert(myObject.bindings[i].method);     
25         }    
26   }  
27 </script>
28         <input type="button" onclick="test()" value="使用这个script" />
29     </body>
30 </html>
31  

上一页  1 2 3 4  下一页

Tags:JSON 进阶

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接