Gson将负载json字符串转为Javabean

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



 
阅读更多
个人分类: android
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭