Gson ignores my fields while converting

前端 未结 3 517
傲寒
傲寒 2021-01-29 09:25

I created a model:

public class UserRequest extends DefaultRequest {
    public String username;
    public String password;
    public String id;

    public Us         


        
3条回答
  •  Happy的楠姐
    2021-01-29 09:47

    Not too familiar with Gson, but I don't think Gson would write null values to an json file. If you initialize the id like:

    String id = "";
    

    you may get an empty string in there. But you will not get a null value into a .xml file.

提交回复
热议问题