zoukankan      html  css  js  c++  java
  • 1*Json对象声明简单,复合,对象数组

    //简单JSON对象
      function btn1_click()
            {
                var json = { "id": 1001, "name": "张三" };
                document.getElementById("txtId").value = json.id;
                document.getElementById("txtName").value = json.name;
            }
    //复合JSON对象
     function btn2_click()
            {
                var json = { "id": 1001, "name": "张三", "phone": {"mobile":"13912345678","home":"66778899"} };
                document.getElementById("txtId").value = json.id;
                document.getElementById("txtName").value = json.name;
                document.getElementById("txtMobile").value = json.phone.mobile;
                document.getElementById("txtHome").value = json.phone.home;
            }
    //JSON对象数组
     function btn3_click()
            {
                var array =
                [
                    { "id": 1001, "name": "张三", "phone":
                                                            { "mobile": "13912345678", "home": "66778899" }
                    },
                    { "id": 1002, "name": "李四", "phone":
                                                        { "mobile": "1301122334", "home": "22334455" }
                    }
                  ];
                    var json = array[1];
                document.getElementById("txtId").value = json.id;
                document.getElementById("txtName").value = json.name;
    document.getElementById(
    "txtMobile").value = json.phone.mobile; document.getElementById("txtHome").value = json.phone.home; }

    var json = new
    {
    total = result.Tag,
    rows = result.Result,
    };
    return Content(Common.JsonHelper.ToJson(json));

     
  • 相关阅读:
    LA3971组装电脑
    LA3971组装电脑
    LA3905流星
    LA3905流星
    LA3902网络
    LA3902网络
    LA3708墓地雕塑
    洛谷 P2330 [SCOI2005]繁忙的都市(最小生成树)
    最小生成树 & 洛谷P3366【模板】最小生成树 & 洛谷P2820 局域网
    洛谷 P1372 又是毕业季I
  • 原文地址:https://www.cnblogs.com/ItDotNet/p/5439554.html
Copyright © 2011-2022 走看看