zoukankan      html  css  js  c++  java
  • JSon数据类型&使用基础

     1 <!DOCTYPE html>
     2 <html>
     3 <head>
     4 <meta charset="UTF-8">
     5 <title>Insert title here</title>
     6     <script type="text/javascript">
     7         function jSon() {
     8             var jSonObject = {"name":"xiaostudy","age":"23"};
     9             alert("jSonObject.name=" + jSonObject.name);
    10             alert("jSonObject.age=" + jSonObject.age);
    11         }
    12         
    13         function jSon2() {
    14             var User = {"name":"xiaostudy","age":"23"};
    15             var User2 = {"name":"xiaostudy2","age":"24"};
    16             var User3 = {"name":"xiaostudy3","age":25};//Number类型
    17             var User4 = {"name":"xiaostudy4", age:26};//String类型
    18             var User5 = {"name":"xiaostudy5", age:27,ft:true};//Boolean类型
    19             var User6 = {"name":"xiaostudy6", age:28,ft:true,array:[1,2,3]};//Array类型
    20             var User7 = {"name":"xiaostudy6", age:28,ft:true,array:[1,2,3], null:null};//null类型
    21             //var jSonObject = [{"name":"xiaostudy","age":"23"}, {"name":"xiaostudy2","age":"24"}];
    22             var jSonObject = [User, User2, User3, User4, User5, User6, User7];//Object类型
    23             
    24             alert("jSonObject[0].name=" + jSonObject[0].name);
    25             alert("jSonObject[1].age=" + jSonObject[1].age);
    26             alert("jSonObject[2].age=" + jSonObject[2].age);
    27             alert("jSonObject[3].age=" + jSonObject[3].age);
    28             alert("jSonObject[4].ft=" + jSonObject[4].ft);
    29             alert("jSonObject[5].array[1]=" + jSonObject[5].array[1]);
    30             alert("jSonObject[6].null=" + jSonObject[6].null);
    31         }
    32         
    33     </script>
    34 </head>
    35 <body>
    36     <p>
    37         var User = {"name":"xiaostudy","age":"23"};<br/>
    38         var User2 = {"name":"xiaostudy2","age":"24"};<br/>
    39         var User3 = {"name":"xiaostudy3","age":25};//Number类型<br/>
    40         var User4 = {"name":"xiaostudy4", age:26};//String类型<br/>
    41         var User5 = {"name":"xiaostudy5", age:27,ft:true};//Boolean类型<br/>
    42         var User6 = {"name":"xiaostudy6", age:28,ft:true,array:[1,2,3]};//Array类型<br/>
    43         var User7 = {"name":"xiaostudy6", age:28,ft:true,array:[1,2,3], null:null};//null类型<br/><br/>
    44         
    45         var jSonObject = [User, User2, User3, User4, User5, User6, User7];//Object类型<br/>
    46     </p>
    47     <input type="button" value="jSon的name" onclick="jSon()"/><br/>
    48     <input type="button" value="jSon" onclick="jSon2()"/><br/>
    49 </body>
    50 </html>

  • 相关阅读:
    小程序路由
    机器学习笔记—支持向量机(1)
    用极大似然估计法推出朴素贝叶斯法中的先验概率估计公式
    机器学习笔记—生成学习
    机器学习笔记—再谈广义线性模型
    机器学习笔记—指数分布簇和广义线性模型
    机器学习笔记—Logistic 回归
    机器学习笔记—局部权重线性回归
    机器学习笔记—线性回归
    机器学习笔记1
  • 原文地址:https://www.cnblogs.com/xiaostudy/p/9601995.html
Copyright © 2011-2022 走看看