Gson deserializes with empty fields

后端 未结 2 1895
甜味超标
甜味超标 2021-01-21 05:09

The result variable contains corrected parsed JSON. But after deserialization List contains correct amount of items but all of the

相关标签:
2条回答
  • 2021-01-21 05:30

    Ok , the problem is that the parser is case-sensitive, you can change the name of your attributes to match the name of the json value of you could use the SerializedName annotation like this:

    @SerializedName("ID")
    public String id ;
    @SerializedName("Name")
        public String name ;
    @SerializedName("Description")
        public String description;
    ...
    

    or

        public String ID ;
        public String Name ;
        public String Description ;
    ...
    
    0 讨论(0)
  • 2021-01-21 05:32

    I think you're having this problem because of null values in your json. Check it. Source

    0 讨论(0)
提交回复
热议问题