码迷,mamicode.com
首页 > Web开发 > 详细

Json简介1

时间:2016-08-21 13:42:29      阅读:138      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!