<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>jsontext</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<script type="text/javascript">
//表示i一个人对象
var pp={"name":"周刚","sex":"男","school":"bjy"}
alert("姓名是:"+pp.name+" 性别:"+pp.sex+" 学校:"+pp.school);
//表示一组人集合对象
var pps=[
{"name":"周刚","sex":"男","school":"bjy"},
{"name":"周刚1","sex":"男1","school":"bjy1"},
{"name":"周刚2","sex":"男2","school":"bjy2"},
{"name":"周刚3","sex":"男3","school":"bjy3"},
{"name":"周刚4","sex":"男4","school":"bjy4"},
{"name":"周刚5","sex":"男5","school":"bjy5"},
{"name":"周刚6","sex":"男6","school":"bjy6"}
]
alert("姓名:"+pps[1].name);
//综合应用
var pps={arr:[
{"name":"周刚","sex":"男","school":"bjy"},
{"name":"周刚1","sex":"男1","school":"bjy1"},
{"name":"周刚2","sex":"男2","school":"bjy2"},
{"name":"周刚3","sex":"男3","school":"bjy3"},
{"name":"周刚4","sex":"男4","school":"bjy4"},
{"name":"周刚5","sex":"男5","school":"bjy5"},
{"name":"周刚6","sex":"男6","school":"bjy6"}
]}
alert("...."+pps.arr);
//实例: 姓名:周刚 性别:男 号码:{手机: 固定电话} 地址:{现住地 家庭住址}
var i={
"name":"周刚","sex":"男",
"pho":[{"phone":"15861411221"},{"phone":"05647467083"}],
"ad":"无锡"
}
alert(i.pho[0].phone);
</script>
</body>
</html>
json
最新推荐文章于 2024-07-10 14:00:00 发布