• 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);
       });

      其效果:

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

  • 相关阅读:
    android 14 进度条和拖动条
    android 13 5种click事件不同实现方式 比较
    android 12 click事件的不同实现方式
    android 11 模拟onclick 事件
    android 10 事件
    android 09
    android 08 AndroidManifest.xml
    android 07 22 23没看
    Linux常用命令last的使用方法详解
    Linux TOP命令 按内存占用排序和按CPU占用排序
  • 原文地址:https://www.cnblogs.com/jingpeipei/p/5960469.html
Copyright © 2020-2023  润新知