关于解析

来源:互联网 发布:c 高级编程第8版 pdf 编辑:程序博客网 时间:2024/05/26 16:00

android开发中,服务器返回我们Json串,我们使用正则表达式把需要的数据进行整理,封装成对象进行使用的过程。只有封装成对象才能使用
服务器给我们返回uri,浏览器打开实际是一串Json串,解析就是把这串Json,变成实体类的过程
json串长这样

{"age":55,"name":"aaa","mDogs":[{"foods":["骨头1","Da骨头1","xiao骨头1"],"name":"旺财1","owner":"xxx1"},{"foods":["骨头2","Da骨头2","xiao骨头2"],"name":"旺财2","owner":"xxx2"}]}

实体类长这样

public class AddTime implements Serializable {    /**     * type : 108     * result : 0     * roomId : 36     * okcount : 0     * addTime : 100     * roomItem : [{"fjxx":{"roomId":36,"perCount":3,"roomState":"已暂停","serverIp":"115.182.35.94:9003","sumTime":2800,"remainingTime":2532,"isNational":0},"yhxx":[{"userId":98,"serverCode":"1640000","policeCode":"2640000","userCode":"0000918812","policeId":97,"roleType":0,"policePhoto":"","userName":"银犯人","userState":"已预约"},{"userId":99,"serverCode":"3640000","policeCode":"","userCode":"0001009037","policeId":0,"roleType":1,"policePhoto":"","userName":"银亲属","userState":"已退出"}],"gjxx":[{"userId":97,"serverCode":"1640000","policeCode":"","userCode":"yck001","policeId":0,"roleType":2,"policePhoto":"http://58.58.26.41:9020/MeetingData/upload/Userprofile/25_20161215054332.jpg","userName":"王静","userState":"登录中"}]}]     */    private int type;    private int result;    private int roomId;    private int okcount;    private int addTime;    private List<RoomItemBean> roomItem;    public int getType() {        return type;    }    public void setType(int type) {        this.type = type;    }    public int getResult() {        return result;    }    public void setResult(int result) {        this.result = result;    }    public int getRoomId() {        return roomId;    }    public void setRoomId(int roomId) {        this.roomId = roomId;    }    public int getOkcount() {        return okcount;    }    public void setOkcount(int okcount) {        this.okcount = okcount;    }    public int getAddTime() {        return addTime;    }    public void setAddTime(int addTime) {        this.addTime = addTime;    }    public List<RoomItemBean> getRoomItem() {        return roomItem;    }    public void setRoomItem(List<RoomItemBean> roomItem) {        this.roomItem = roomItem;    }}