码迷,mamicode.com
首页 > Web开发 > 详细

json

时间:2015-06-05 18:03:14      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
       <ul>
		 <li id="bj" name="beijing">北京</li>
	   </ul>
  </body>
  
  <script language="JavaScript">
	/**
	 * 案例一
	 *  {key:value,key:value}
	 *  
	 * class Person{
	 * 	  String firstname = "张";
	 *    String lastname = "三丰";
	 *    Integer age = 100;
	 * }
	 * 
	 * Person p = new Person();
	 * System.out.println(p.firstname);
	 */
	var p = [{firtstName:"zhang",lastName:"sanfen",age:100},{firtstName:"zhang",lastName:"sanfen",age:10}];
	alert(p[0].lastName + "  and  " + p[1].age);
	var p = {"name":["zhang",{sanfen:"sanfen11"}]};
	alert(p.name[1].sanfen);
  </script>
</html>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>insertBefore.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  </head>
  <body>
       <ul>
		 <li id="bj" name="beijing">北京</li>
	   </ul>
  </body>
  
  <script language="JavaScript">
  	/**
	 * 案例二
	 *  [{key:value,key:value},{key:value,key:value}]
	 *  
	 */
	var array = [{name:‘张‘,age:19},{name:‘李‘,lastname:‘天一‘,age:17}]
	alert(array[0].name);
	alert(array[1].age);
	
  </script>
</html>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>insertBefore.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  </head>
  <body>
       <ul>
		 <li id="bj" name="beijing">北京</li>
	   </ul>
  </body>
  
  <script language="JavaScript">
   /**
	 * 案例三
	 * {
	 *   "param":[{key:value,key:value},{key:value,key:value}]
	 * }
	 *  
	 *  
	 */
	var obj = {name:‘林夕‘,family:[{name:‘双江‘,age:75},{name:‘skyone‘,age:17}]};
	alert(obj.family[1].name)
	
  </script>
</html>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>insertBefore.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  </head>
  <body>
       <ul>
		 <li id="bj" name="beijing">北京</li>
	   </ul>
  </body>
  
  <script language="JavaScript">
   /**
	 * 案例四
	 * {
	 *   "param1":[{key:value,key:value},{key:value,key:value}],
	 *   "param2":[{key:value,key:value},{key:value,key:value}],
	 *   "param3":[{key:value,key:value},{key:value,key:value}]
	 * }
	 */
		
		var obj = {
			"man":[{name:‘张无忌‘,age:19},{name:‘张翠山‘,age:40}],
			"woman":[{name:‘赵敏‘,age:16},{name:‘芷若妹子‘,age:20},{name:‘灭绝师太‘,age:18}],
			"妖":[{name:‘轻易福王‘,age:19},{name:‘金毛狮王‘,age:55}]			
		}
		alert(obj.妖[1].age);
	
	
  </script>
</html>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>insertBefore.html</title>
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  </head>
  <body>
       <ul>
		 <li id="bj" name="beijing">北京</li>
	   </ul>
  </body>
  
  <script language="JavaScript">
  	/**
  	 * 		案例五: 
  	 * 		Person {
						"key":"value",					  
						"key":"value",					  
						"key":{"key":"value","key":"value"},
						"key":[
									{"key":"value","key":"value"},
									{"key":"value","key":"value"}
							  ]
				     }	
  	 */
	
	var obj = {
			刘备:‘孙上香‘,
			孙权:‘大乔‘,
			曹操:{name1:‘赤兔马‘,name2:‘小巧‘,name3:‘貂蝉‘},
			小宝:[
				{name:‘双儿‘,age:19},
				{name:‘建宁公主‘,age:15}
			]
	}
	alert(obj.小宝[1].name)
	
  </script>
</html>




json

标签:

原文地址:http://my.oschina.net/u/2356176/blog/425356

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!