{ meta: { limit: 0, offset: 0, total_count: 49 }, objects: [ { category: "Певец/Певица", created_at: "2016-07-04T11:27:49.050021", description: "hccjcj ", email: "xcjcu@hh.ru", extra_phone_number: "8582838", id: 64, name: "гаггсгссгссгсгсгсгсшмшмшп", phone_number: "688838383838388383", photo_url: "", price: 6868, resource_uri: "/api/post/64/", surname: "осоммомгп", updated_at: "2016-07-04T11:27:49.050069", video_url: null }, { category: "Тамада", created_at: "2016-07-04T08:03:58.411222", description: "gsgvs", email: "sgha@ejs.com", extra_phone_number: "5465", id: 63, name: "ysuhhs", phone_number: "0123456789", photo_url: "", price: 1235, resource_uri: "/api/post/63/", surname: "gsjeg", updated_at: "2016-07-04T08:03:58.411287", video_url: null },
This json needs to be converted into objects of class Person. these objects are grouped into categories.
Data list = new Gson().fromJson(json,Data.class); return list.getList().size();
issues a NullPointerExeption.
public class Data implements Serializable{ private List<Person> list; public void setList(List<Person> list) { this.list = list; } public List<Person> getList() { return list; } }
Person class
public class Person implements Serializable { String name; String surname; String category; String price; String bitmap; String description; String region; String created_at; String email; String phone_number; String video_url; String id; + setters & getters }