<!DOCTYPE html>
<html>
<head>
<title>01_json.html</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
This is my HTML page. <br>
</body>
<script type="text/javascript">
/*
* 构建符合"key/value"格式的JSON数据格式
* * 是以"{}"开始和结束的
* * 数据格式是以"key/value"格式存在
* * key/value之间使用":"隔开
* * 多个数据之间使用","隔开
* * 访问JSON格式的value值:json格式名称.key
*/
var person = {
name : "zhangwuji",
age : 18,
sex : "male"
}
alert(person.name);
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<title>02_json.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>
This is my HTML page. <br>
</body>
<script type="text/javascript">
/*
* 构建符合数组格式的JSON数据格式:javascript里的数组完全一致
*/
var person = ["person1","person2","person3"];
alert(person[0]);
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<title>03_json.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>
This is my HTML page. <br>
</body>
<script type="text/javascript">
var person = [
{
name : "zhangwuji",
age : 18,
sex : "male"
},
{
name : "zhouzhiruo",
age : 18,
sex : "female"
}
];
alert(person[0].name);
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<title>04_json.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>
This is my HTML page. <br>
</body>
<script type="text/javascript">
var person = {
"yttlj":
[
{
name : "zhangwuji",
age : 18,
sex : "male"
},
{
name : "zhouzhiruo",
age : 18,
sex : "female"
}
],
"tlbb":
[
{
name : "xuzhu",
age : 18,
sex : "male"
},
{
name : "menggu",
age : 18,
sex : "female"
}
]
}
alert(person.tlbb[0].name);
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<title>05_json.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>
This is my HTML page. <br>
</body>
<script type="text/javascript">
// var person = {
// "wuxia":
// {
// "yttlj":
// [
// {
// name : "zhangwuji",
// age : 18,
// sex : "male"
// },
// {
// name : "zhouzhiruo",
// age : 18,
// sex : "female"
// }
// ],
// "tlbb":
// [
// {
// name : "xuzhu",
// age : 18,
// sex : "male"
// },
// {
// name : "menggu",
// age : 18,
// sex : "female"
// }
// ]
// },
// "yanqing":
// {
// "hzgg":
// [
// {
// name : "wuage",
// age : 18,
// sex : "male"
// },
// {
// name : "xiaoyanzi",
// age : 18,
// sex : "female"
// }
// ],
// "qssymm":
// [
// {
// name : "heshuhuan",
// age : 18,
// sex : "male"
// },
// {
// name : "luyiping",
// age : 18,
// sex : "female"
// }
// ]
// }
// }
// var person = {
// name : "xxx",
// age : 18,
// sex : "male",
// address : {
// "home":"xxshixxqu",
// "family":"yyshiyyqu"
// }
// };
//将javascript代码实现块状结构
var method = {
add : function(a,b){
return a + b;
}
}
alert(method.add(1,2)); //output 3
//alert(person.yanqing.hzgg[0].name);
</script>
</html>