使用GSON库将JSON信封转换为List时,仅显示第一条记录。为什么不显示所有记录?有关json信封,将json转换为列表以及项目模型的详细信息,请参见下文。
JSON信封:
[{
"id_cur_profil":"2",
"account_type":"job_provider",
"notification":[
{
"id_profil_request":"124",
"Name":"Buff Dudes",
"city":"Namur",
"activite":"Badminton",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-54ae5120d0a479.27096492.jpg",
"agenda":[
{
"day":"Wednesday",
"from":"09:00:00",
"to":"17:00:00"
},
{
"day":"Thursday",
"from":"09:00:00",
"to":"10:00:00"
}
]
},
{
"id_profil_request":"180",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Aikido",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
{
"day":"Monday",
"from":"09:00:00",
"to":"13:00:00"
}
]
},
{
"id_profil_request":"209",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Athletiek",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
{
"day":"Monday",
"from":"09:00:00",
"to":"13:00:00"
},
{
"day":"Tueday",
"from":"13:00:00",
"to":"21:00:00"
}
]
},
{
"id_profil_request":"242",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Tai Shi",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"243",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"244",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"245",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"246",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"247",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"248",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
{
"day":"{\"wednesday",
"from":"09:00:00",
"to":"17:00:00"
}
]
},
{
"id_profil_request":"249",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"253",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"254",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"255",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
{
"day":"%22%22",
"from":"00:00:00",
"to":"00:00:00"
}
]
},
{
"id_profil_request":"256",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"257",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
{
"day":"\"\"",
"from":"00:00:00",
"to":"00:00:00"
}
]
},
{
"id_profil_request":"258",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"259",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
{
"day":"monday",
"from":"13:00:00",
"to":"16:00:00"
}
]
},
{
"id_profil_request":"260",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
{
"day":"monday",
"from":"13:00:00",
"to":"16:00:00"
}
]
},
{
"id_profil_request":"261",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"267",
"Name":"Annabelle Blaze",
"city":"Waterloo",
"activite":"Aerobic",
"logo":"https:\/\/app.com\/img\/profil_pic\/jobber-5534a8c57fcf57.42394869.jpg",
"agenda":[
]
},
{
"id_profil_request":"284",
"Name":"Jobber Pro",
"city":"Namur",
"activite":"Boxe Thai",
"logo":"https:\/\/app.com\/img\/profil_pic\/",
"agenda":[
]
}
]
}]
将json转换为list的方法。
public List<MyNotification> saveJson(String envelop){
Type listType = new TypeToken<ArrayList<MyNotification>>() {}.getType();
List<MyNotification> search_results = new Gson().fromJson(envelop, listType);
return search_results;
}
Json模型
public class MyNotification {
public boolean no_record=false;
public String error_message;
public String id_cur_profil;
public String account_type;
public ArrayList<Notification> notification;
public class Notification {
public String id_profil_request;
public String name;
public String city;
public String id_cur_profil;
public String activite;
public String logo;
public ArrayList<Agenda> agenda;
}
public MyNotification(boolean b,String error_message) {
// TODO Auto-generated constructor stub
this.no_record = b;
this.error_message=error_message;
}
}