首页 > Web开发 > 详细

Json简介1

时间:2016-08-21 13:39:54      阅读:162      评论:0      收藏:0      [点我收藏+]

技术分享

技术分享技术分享

 

 技术分享

技术分享

使用Notepad++编程:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Json Practice</title>
<script type="text/javascript">
var obj1={user:"John",age:22,country:"China"};
var obj2={user:"Mike",age:33,country:"Brazil"};
var obj3={user:"Tony",age:11,country:"Korea"};
var obj4={u1:obj1, u2:obj2, u3:obj3};
document.write(obj1.user+" is "+obj1.age+" years old "+"from "+obj1.country);
obj1.country="Mexio";
document.write("<hr/>");
document.write(obj1.user+" is "+obj1.age+" years old "+"from "+obj1.country);
document.write("<hr/>");
document.write(obj4.u2.name+" is "+obj4.u2.age+" years old "+" from "+obj4.u2.country);
document.write("<hr/>");
document.write(obj4.u3.country);
document.write("<hr/>");
document.write(obj4["u3"]["country"]);
</script>
</head>
<body>
</body>
</html>

结果:

技术分享

 

 技术分享

技术分享

注意:注释不能用<!--  -->,不然无法显示,用//来注释,亲测。

Json简介1

原文:http://www.cnblogs.com/stm32stm32/p/5792489.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!