Heim > Fragen und Antworten > Hauptteil
请问如何把日期放到所归lists上面,求思路!!!
Json数据如下:
{"code":1,"message":"团队已使用模板返回成功","result":[{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]},{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]},{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]},{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]}]}
大家讲道理2017-04-17 17:59:12
那样做反而冗余了吧,list目前和data处于同一级别,可以构造如下的bean类:
public class TestBean {
/**
* code : 1
* message : 团队已使用模板返回成功
* result : [{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]},{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]},{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]},{"date":"2016-12-05","lists":[{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]}]
*/
private int code;
private String message;
private List<ResultBean> result;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<ResultBean> getResult() {
return result;
}
public void setResult(List<ResultBean> result) {
this.result = result;
}
public static class ResultBean {
/**
* date : 2016-12-05
* lists : [{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"},{"category":"浪漫类","create_at":"转发时间","id":"4","mind":"必发提醒1提醒0不提醒","name":"巴黎之夜","thumb":"http://192.168.0.18/Uploads/weiretrans/thumb.png","times":"1转发次数","useis":"1当前用户是否已使用1是0否"}]
*/
private String date;
private List<ListsBean> lists;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public List<ListsBean> getLists() {
return lists;
}
public void setLists(List<ListsBean> lists) {
this.lists = lists;
}
public static class ListsBean {
/**
* category : 浪漫类
* create_at : 转发时间
* id : 4
* mind : 必发提醒1提醒0不提醒
* name : 巴黎之夜
* thumb : http://192.168.0.18/Uploads/weiretrans/thumb.png
* times : 1转发次数
* useis : 1当前用户是否已使用1是0否
*/
private String category;
private String create_at;
private String id;
private String mind;
private String name;
private String thumb;
private String times;
private String useis;
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getCreate_at() {
return create_at;
}
public void setCreate_at(String create_at) {
this.create_at = create_at;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getMind() {
return mind;
}
public void setMind(String mind) {
this.mind = mind;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getThumb() {
return thumb;
}
public void setThumb(String thumb) {
this.thumb = thumb;
}
public String getTimes() {
return times;
}
public void setTimes(String times) {
this.times = times;
}
public String getUseis() {
return useis;
}
public void setUseis(String useis) {
this.useis = useis;
}
}
}
}
使用ListsBean时可以调用父类ResultBean的getDate获取日期。