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": "\u5317\u4eac",
        "weather_data": [{
            "date": "\u5468\u4e8c(\u4eca\u5929, \u5b9e\u65f6\uff1a22\u2103)",
            "dayPictureUrl": "http:\/\/www.baidu.com\/aladdin\/img\/new_weath\/bigicon\/7.png",
            "nightPictureUrl": "http:\/\/api.map.baidu.com\/images\/weather\/night\/yin.png",
            "weather": "\u973e\u8f6c\u9634",
            "wind": "\u5fae\u98ce",
            "temperature": "23 ~ 11\u2103",
            "dayPictureurl": "http:\/\/api.map.baidu.com\/images\/weather\/day\/mai.png"
        },
        {
            "date": "\u5468\u4e09",
            "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": "\u5fae\u98ce",
            "temperature": "21 ~ 11\u2103"
        },
        {
            "date": "\u5468\u56db",
            "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": "\u5317\u98ce3-4\u7ea7",
            "temperature": "21 ~ 10\u2103"
        },
        {
            "date": "\u5468\u4e94",
            "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": "\u5fae\u98ce",
            "temperature": "24 ~ 9\u2103"
        }]
    }]
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值