Json简介1-LMLPHP

Json简介1-LMLPHPJson简介1-LMLPHP

Json简介1-LMLPHP

Json简介1-LMLPHP

使用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-LMLPHP

Json简介1-LMLPHP

Json简介1-LMLPHP

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

05-11 01:37