关闭

Gson将负载json字符串转为Javabean

73人阅读 评论(0) 收藏 举报
分类:
package com.hairun.sdm.com.Statistics.Cutover.dwonEntry;

import java.util.List;

/**
 * Created by hr on 2016/5/30.
 */
public class DwonCutover {

    private String result;//结果码
    private String message;//消息
    private List<Cutover> datas;
    public  class Cutover{
        private String taskId;//起始任务编号
        private String startTime;//起始时间
        private String appName;//测试名称
        private String times;//次数
        public String getTaskId() {
            return taskId;
        }

        public void setTaskId(String taskId) {
            this.taskId = taskId;
        }

        public String getStartTime() {
            return startTime;
        }

        public void setStartTime(String startTime) {
            this.startTime = startTime;
        }
        public String getAppName() {
            return appName;
        }

        public void setAppName(String appName) {
            this.appName = appName;
        }

        public String getTimes() {
            return times;
        }

        public void setTimes(String times) {
            this.times = times;
        }
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public List<Cutover> getDatas() {
        return datas;
    }

    public void setDatas(List<Cutover> datas) {
        this.datas = datas;
    }
}
//示例
final NetUtil netUtil = new NetUtil(this);
netUtil.isDwondata();
netUtil.getJsonObjectFromServer(HttpUrl.BaseUrl + "ResultContoller/getCutoverList.do", map, true, new Response.Listener<String>() {
    @Override
    public void onResponse(String s) {
        mLog.show("-------cut------------",s);
        netUtil.dismiss();
        Gson gson = new Gson();
        DwonCutover dwonCutover = gson.fromJson(s,new TypeToken<DwonCutover>(){}.getType());
        if(null!=dwonCutover&&!"0".equals(dwonCutover.getResult())){
            List<DwonCutover.Cutover> cutList= dwonCutover.getDatas();
            adapter =new CutoverStaticAdapter(CutoverMainActivity.this,cutList);
            listView.setAdapter(adapter);
        }else{
            MyToast.onShow(CutoverMainActivity.this, dwonCutover.getMessage());
            netUtil.dismiss();
        }
    }
});



 
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:10671次
    • 积分:457
    • 等级:
    • 排名:千里之外
    • 原创:35篇
    • 转载:9篇
    • 译文:1篇
    • 评论:0条
    文章分类