Есть JSON объект:
Код | { "user1": { "timeSpent": "20.533333333333335h", "worklog": [ { "date": "06/26/2013", "issues": [ { "issueCode": "COC-2", "comment": "\ncccccc", "timeSpent": "20.533333333333335h" } ], "dayTotal": "20.533333333333335h" } ] }, "admin": { "timeSpent": "601.1h", "worklog": [ { "date": "06/25/2013", "issues": [ { "issueCode": "COC-1", "comment": "", "timeSpent": "113.1h" } ], "dayTotal": "113.1h" }, { "date": "06/26/2013", "issues": [ { "issueCode": "COC-1", "comment": "", "timeSpent": "8h" }, { "issueCode": "COC-2", "comment": "", "timeSpent": "480h" } ], "dayTotal": "488h" } ] } }
|
Его я пробую распарсить при помощи GSON:
Код | Gson gson = new Gson(); Book responseBean = gson.fromJson(jsonString, Book.class);
|
Где класс Book представляет из себя:
Код | public class Book{
private List<User> userData;
public List<User> getUserData() { return userData; }
public void setUserData(List<User> userData) { this.userData = userData; } }
|
Код | public class User { private String timeSpent; private List<WorkLog> worklogs;
public List<WorkLog> getWorklogs() { return worklogs; }
public void setWorklogs(List<WorkLog> worklogs) { this.worklogs = worklogs; }
public String getTimeSpent() { return timeSpent; }
public void setTimeSpent(String timeSpent) { this.timeSpent = timeSpent; } }
|
Код | public class WorkLog{ private String date; private String dayTotal; private List<Issues> issues;
public String getDate(){ return this.date; } public void setDate(String date){ this.date = date; } public String getDayTotal(){ return this.dayTotal; } public void setDayTotal(String dayTotal){ this.dayTotal = dayTotal; } public List<Issues> getIssues(){ return this.issues; } public void setIssues(List<Issues> issues){ this.issues = issues; } }
|
Код | public class Issues{ private String comment; private String issueCode; private String timeSpent;
public String getComment(){ return this.comment; } public void setComment(String comment){ this.comment = comment; } public String getIssueCode(){ return this.issueCode; } public void setIssueCode(String issueCode){ this.issueCode = issueCode; } public String getTimeSpent(){ return this.timeSpent; } public void setTimeSpent(String timeSpent){ this.timeSpent = timeSpent; } }
|
После запуска responseBean у меня всегда null. Пробовал много разных вариантов, это последний. Что-то я совсем запутался, буду очень благодарен за помощь. |