zoukankan      html  css  js  c++  java
  • Struts2 JSON

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式
     (本质是一种数据传输格式)

     定义json对象

    var json={"firstName":"hehe","secondName":"he","thirdName":"heh"};
         
         
         $.each(json,function(i,dom){
            alert(dom);
         });

    效果:

     定义json数组

     

     var json=
         {
        "people":[
            {"firstName":"孙悟空","lastName":"大闹天宫","email":"aaaa"},
            {"firstName":"美猴王","lastName":"花果山山大王","email":"bbbb"},
            {"firstName":"大圣","lastName":"天上各位尊神尊称他","email":"cccc"},
              {"firstName":"弼马温","lastName":"人生第一份工作","email":"DDDD"}
        ]
       };
       
       $.each(json.people,function(i,dom){
            alert(d

    效果:

     var json={
        "programmers": [{
            "firstName": "Brett",
            "lastName": "McLaughlin",
            "email": "aaaa"
        }, {
            "firstName": "Jason",
            "lastName": "Hunter",
            "email": "bbbb"
        }, {
            "firstName": "Elliotte",
            "lastName": "Harold",
            "email": "cccc"
        }],
        "authors": [{
            "firstName": "Isaac",
            "lastName": "Asimov",
            "genre": "sciencefiction"
        }, {
            "firstName": "Tad",
            "lastName": "Williams",
            "genre": "fantasy"
        }, {
            "firstName": "Frank",
            "lastName": "Peretti",
            "genre": "christianfiction"
        }],
        "musicians": [{
            "firstName": "Eric",
            "lastName": "Clapton",
            "instrument": "guitar"
        }, {
            "firstName": "Sergei",
            "lastName": "Rachmaninoff",
            "instrument": "piano"
        }]
    };
         $.each(json.programmers,function(i,dom){
            alert(dom.firstName+"
    "+dom.lastName+"
    "+dom.instrument);
       });

      其效果:

    其它都一样,就不一一截图了

  • 相关阅读:
    进阶面向对象(下)
    进阶面向对象(上)
    使用WIFI准备工作及配置内核——韦东山
    USB设备驱动程序1
    USB总线驱动程序
    USB驱动程序涉及的概念及框架
    I2C协议简介
    倾旋之slack主题协同
    1.影子制作
    11.快速选择工具
  • 原文地址:https://www.cnblogs.com/jingpeipei/p/5960469.html
Copyright © 2011-2022 走看看