JSON

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript">
	var json = [
		{
			"empno": "001",
			"ename": "李宁",
			"job": "软件工程师",
			"hiredate": "2020-7-15",
			"salary": "9500"
		},
		{
			"empno": "002",
			"ename": "张三",
			"job": "客户经理",
			"hiredate": "2020-7-15",
			"salary": "9500",
			"customer": [
				{
					"cname": "王五"
				},
				{
					"cname": "罗翔"
				}
			]
		}
	];
	console.log(json);
	for(var i=0; i<json.length; i++){
		var emp = json[i];
		document.write("<h1>");
		document.write(emp.empno);
		document.write("," + emp.job);
		document.write("," + emp.hiredate);
		document.write("," + emp.salary);
		document.write("</h1>");
		if(emp.customer != null){
			document.write("<h2>");
			for( var j=0; j<emp.customer.length; j++){
				var customer = emp.customer[j];
				document.write(customer.cname + ",");
			}
			document.write("</h2>");
		}
	}
</script>
<body>

</body>
</html>

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值