Parse List of JSON objects using GSON

后端 未结 2 924
旧时难觅i
旧时难觅i 2021-01-03 07:14

I have a JSON object like this:

{
  \"user1\": {
    \"timeSpent\": \"20.533333333333335h\",
    \"worklog\": [
      {
        \"date\": \"06/26/2013\",
            


        
2条回答
  •  走了就别回头了
    2021-01-03 07:21

    I had some problem before a month. As far as I remember it was because, same as you, I forgot to make "new" to objects. I mean that it should look:

    public class User {
        private String timeSpent;
        private List worklogs = new List < WorkLog >();
    }
    

    Try this and I hope that it will help.

    P.S. Also as Erik Pragt said you have array of Users, not just single one. So you will have to make 1 more class that contains a List < Users >.

提交回复
热议问题