zoukankan      html  css  js  c++  java
  • Json的解析

    Result:
    {
        "project": {
            "code": "lmx",
            "description": "",
            "firstparty": "",
            "id": 161,
            "isdelete": "n",
            "managercode": "AAA",
            "managername": "",
            "membercode": "",
            "membername": "",
            "milestonestate": "",
            "name": "lmx",
            "ownercode": "",
            "ownername": "",
            "secondparty": "",
            "shortname": "lmx",
            "type": ""
        },
    
        "projectWeek": "",
        "missNextWeekList": [{
            "code": "lmx001",
            "content": "",
            "description": "",
            "endtime": "2015-08-19",
            "finishtime": "2015-08-15",
            "id": 161,
            "managercode": "",
            "managername": "",
            "name": "lmx001",
            "priority": "",
            "projectcode": "lmx",
            "projectname": "",
            "publishtime": "",
            "receivercode": "LLL",
            "receivername": "",
            "receivetime": "2015-08-13",
            "starttime": "2015-08-13",
            "state": "1",
            "timecost": ""
        },
        {
            "code": "lmx004",
            "content": "",
            "description": "",
            "endtime": "2015-08-26",
            "finishtime": "",
            "id": 164,
            "managercode": "",
            "managername": "",
            "name": "lmx004",
            "priority": "",
            "projectcode": "lmx",
            "projectname": "",
            "publishtime": "",
            "receivercode": "HHH",
            "receivername": "",
            "receivetime": "2015-08-17",
            "starttime": "2015-08-13",
            "state": "1",
            "timecost": ""
        }],
        "missThisWeekList": [{
            "code": "lmx001",
            "content": "",
            "description": "",
            "endtime": "2015-08-19",
            "finishtime": "2015-08-15",
            "id": 161,
            "managercode": "",
            "managername": "",
            "name": "lmx001",
            "priority": "",
            "projectcode": "lmx",
            "projectname": "",
            "publishtime": "",
            "receivercode": "LLL",
            "receivername": "",
            "receivetime": "2015-08-13",
            "starttime": "2015-08-13",
            "state": "1",
            "timecost": ""
        },
        {
            "code": "lmx004",
            "content": "",
            "description": "",
            "endtime": "2015-08-26",
            "finishtime": "",
            "id": 164,
            "managercode": "",
            "managername": "",
            "name": "lmx004",
            "priority": "",
            "projectcode": "lmx",
            "projectname": "",
            "publishtime": "",
            "receivercode": "HHH",
            "receivername": "",
            "receivetime": "2015-08-17",
            "starttime": "2015-08-13",
            "state": "1",
            "timecost": ""
        }],
        "missFinshCount": 1,
        "missRunningCount": 3,
        "memberCount": 4
    }
    

      

     List list = staffService.loadAllStaff(name);  
     for(int i=0;i<list.size();i++){
         Staff sta = (Staff)list.get(i);
         System.out.println(sta.getName()+"   "+sta.getCode());
     }
     JSONArray jsonArr = JSONUtil.toJSONArray(list);
     System.out.println("获得的JSON字符串为:"+jsonArr); 
    

      

     
    输出结果:
    存入模式:讲list一个个存入。
    直接解析:result代表第一个list内数据
    result[1].cellphone
     
    [{
        "cellphone": "4",
        "certification": "",
        "code": "4",
        "email": "5",
        "experience": "",
        "id": 134,
        "name": "4",
        "other": "",
        "qq": "",
        "remark": "",
        "skill": "",
        "wechat": ""
    },
    {
        "cellphone": "543543",
        "certification": "",
        "code": "43543",
        "email": "543543543",
        "experience": "",
        "id": 133,
        "name": "43543",
        "other": "",
        "qq": "",
        "remark": "",
        "skill": "",
        "wechat": ""
    },
    {
        "cellphone": "123213",
        "certification": "123213",
        "code": "123213",
        "email": "123213",
        "experience": "123213",
        "id": 101,
        "name": "123213",
        "other": "123213",
        "qq": "123213",
        "remark": "",
        "skill": "123213",
        "wechat": "123213"
    },
    {
        "cellphone": "765765",
        "certification": "",
        "code": "aaa",
        "email": "657657657777776555777777",
        "experience": "",
        "id": 99,
        "name": "AAA",
        "other": "",
        "qq": "77657657",
        "remark": "",
        "skill": "",
        "wechat": ""
    },
    {
        "cellphone": "113243243243223",
        "certification": "435435",
        "code": "woshidaima",
        "email": "1132432432432",
        "experience": "435435435",
        "id": 98,
        "name": "6",
        "other": "435435",
        "qq": "123",
        "remark": "45435435435435435",
        "skill": "435435435",
        "wechat": "435435435"
    },
    {
        "cellphone": "2",
        "certification": "435",
        "code": "234",
        "email": "2",
        "experience": "54354343",
        "id": 97,
        "name": "2",
        "other": "543543",
        "qq": "34543",
        "remark": "543543",
        "skill": "435435",
        "wechat": "435435"
    }]
    json数组,是直接把list放到一个
    存入模式,list配一个key后存入。
    解析:
    var code=result.missNextWeekList[0].code;
     
    {
        "error": 0,
        "status": "success",
        "date": "2014-04-01",
        "results": [{
            "currentCity": "u5317u4eac",
            "weather_data": [{
                "date": "u5468u4e8c(u4ecau5929, u5b9eu65f6uff1a22u2103)",
                "dayPictureUrl": "http://www.baidu.com/aladdin/img/new_weath/bigicon/7.png",
                "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/yin.png",
                "weather": "u973eu8f6cu9634",
                "wind": "u5faeu98ce",
                "temperature": "23 ~ 11u2103",
                "dayPictureurl": "http://api.map.baidu.com/images/weather/day/mai.png"
            },
            {
                "date": "u5468u4e09",
                "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/yin.png",
                "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/yin.png",
                "weather": "u9634",
                "wind": "u5faeu98ce",
                "temperature": "21 ~ 11u2103"
            },
            {
                "date": "u5468u56db",
                "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/qing.png",
                "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/qing.png",
                "weather": "u6674",
                "wind": "u5317u98ce3-4u7ea7",
                "temperature": "21 ~ 10u2103"
            },
            {
                "date": "u5468u4e94",
                "dayPictureUrl": "http://api.map.baidu.com/images/weather/day/qing.png",
                "nightPictureUrl": "http://api.map.baidu.com/images/weather/night/qing.png",
                "weather": "u6674",
                "wind": "u5faeu98ce",
                "temperature": "24 ~ 9u2103"
            }]
        }]
    }
  • 相关阅读:
    Vue + better-scroll 入门教程
    Vue + Vant 实现顶部关键字搜索栏
    JS实现函数节流方法
    AngularJS服务及注入--Provider
    入门Webpack,看这篇就够了
    Vue.js中ref ($refs)用法举例总结
    从0开始做一个的Vue图片/ 文件选择(上传)组件[基础向]
    gulp自动化部署:gulp发布express项目(二)
    webstorm添加调试nodejs
    web window pixel等笔记
  • 原文地址:https://www.cnblogs.com/luoxuehuan/p/4807854.html
Copyright © 2011-2022 走看看