Gson fromJson() returns object with null attrubutes

后端 未结 3 1283
醉话见心
醉话见心 2021-01-17 14:58

I\'m trying to create some Java objects using this line:

Quiz currentQuiz = gson.fromJson(json, Quiz.class);

But the all I get is this:

3条回答
  •  不知归路
    2021-01-17 15:28

    In my case I had deleted

    @SerializedName("OpCode")
    @Expose
    

    parts from my model class which are above the

    private Integer opCode;
    

    line. And so Gson could not parse it and so my attributes were null. When I added those lines it fixed.

提交回复
热议问题