<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.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">
</head>
<body>
</body>
<script language="JavaScript">
/*
* class Person{
*
* private String name;
* private String age;
* private String sex;
* 省略的set和get方法
* }
*
* Person person = new Person();
*
* person.name;
* person.age;
*
* json数据格式:相当于一个map集合
* * 是以"{}"开始和结尾的
* * 里面是以"key/value"键值对形式存在
* * "key/value"之间使用":"隔开
* * 多个"key/value"之间使用","隔开
*
* {
* key01:value01,
* key02:value02
* }
*
*
*/
var person = {
"name":"zhangwuji",
"age":"18",
"sex":"male"
}
alert(person.age);
</script>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.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">
</head>
<body>
</body>
<script language="JavaScript">
/*
* class Person{
*
* private String name;
* private String age;
* private String sex;
* 省略的set和get方法
* }
*
* Person person = new Person();
*
* person.name;
* person.age;
*
* json数据格式:相当于一个数组
* * 是以"[]"开始和结尾的
* * 里面是以多个值存在
* * 其中,每个值是map集合存在,map集合里是以"key/value"键值对形式存在
* * 多个值之间用","隔开
*
* [
* {
* key01:value01,
* key02:value02
* },
* {
* key01:value01,
* key02:value02
* }
* ]
*
*
*
*/
var person = [
{
"name":"zhangwuji",
"age":"18",
"sex":"male"
},
{
"name":"zhouzhiruo",
"age":"18",
"sex":"female"
}
]
alert(person[1].name);
</script>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.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">
</head>
<body>
</body>
<script language="JavaScript">
/*
* class Person{
*
* private String name;
* private String age;
* private String sex;
* 省略的set和get方法
* }
*
* Person person = new Person();
*
* person.name;
* person.age;
*
* json数据格式:相当于一个数组
* * 是以"[]"开始和结尾的
* * 里面是以多个值存在
* * 其中,每个值是map集合存在,map集合里是以"key/value"键值对形式存在
* * 多个值之间用","隔开
*
* [
* {
* key01:value01,
* key02:value02
* },
* {
* key01:value01,
* key02:value02
* }
* ]
*
*
*
*/
var person = {
"yttlj":
[
{
"name":"zhangwuji",
"age":"18",
"sex":"male"
},
{
"name":"zhouzhiruo",
"age":"18",
"sex":"female"
}
]
}
alert(person.yttlj[1].name);
</script>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.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">
</head>
<body>
</body>
<script language="JavaScript">
/*
* class Person{
*
* private String name;
* private String age;
* private String sex;
* 省略的set和get方法
* }
*
* Person person = new Person();
*
* person.name;
* person.age;
*
* json数据格式:相当于一个数组
* * 是以"[]"开始和结尾的
* * 里面是以多个值存在
* * 其中,每个值是map集合存在,map集合里是以"key/value"键值对形式存在
* * 多个值之间用","隔开
*
* [
* {
* key01:value01,
* key02:value02
* },
* {
* key01:value01,
* key02:value02
* }
* ]
*
*
*
*/
var person = [
{
"yttlj":
[
{
"name":"zhangwuji",
"age":"18",
"sex":"male"
},
{
"name":"zhouzhiruo",
"age":"18",
"sex":"female"
}
]
},
{
"sdyxz":
[
{
"name":"guojing",
"age":"18",
"sex":"male"
},
{
"name":"huangrong",
"age":"18",
"sex":"female"
}
]
}
]
alert(person[1].sdyxz[1].name);
</script>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.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">
</head>
<body>
</body>
<script language="JavaScript">
/*
* class Person{
*
* private String name;
* private String age;
* private String sex;
* 省略的set和get方法
* }
*
* Person person = new Person();
*
* person.name;
* person.age;
*
* json数据格式:相当于一个数组
* * 是以"[]"开始和结尾的
* * 里面是以多个值存在
* * 其中,每个值是map集合存在,map集合里是以"key/value"键值对形式存在
* * 多个值之间用","隔开
*
* [
* {
* key01:value01,
* key02:value02
* },
* {
* key01:value01,
* key02:value02
* }
* ]
*
* * json数据格式可以无限嵌套下去,但是建议最多三层
*
*/
// var person = {
// "jinyong":
// [
// {
// "yttlj":
// [
// {
// "name":"zhangwuji",
// "age":"18",
// "sex":"male"
// },
// {
// "name":"zhouzhiruo",
// "age":"18",
// "sex":"female"
// }
// ]
// },
// {
// "sdyxz":
// [
// {
// "name":"guojing",
// "age":"18",
// "sex":"male"
// },
// {
// "name":"huangrong",
// "age":"18",
// "sex":"female"
// }
// ]
// }
// ],
// "qingyao":
// [
// {
// "hzgg":
// [
// {
// "name":"erkang",
// "age":"18",
// "sex":"male"
// },
// {
// "name":"ziwei",
// "age":"18",
// "sex":"female"
// }
// ]
// },
// {
// "qssymm":
// [
// {
// "name":"dufei",
// "age":"18",
// "sex":"male"
// },
// {
// "name":"ruping",
// "age":"18",
// "sex":"female"
// }
// ]
// }
// ]
// }
var person = {
name:"xxx",
age:"xxx",
address:[
{home:"xxshixxxqu"},
{family:"yyshiyyqu"}
]
}
//普通方法
function add(a,b){
return a+b;
}
add(3,4);
//使用json来定义函数
var method = {
add:function(a,b){
return a+b;
}
}
method.add(3,4);
alert(person.qingyao[0].hzgg[1].name);
</script>
</html>