Gson ignores my fields while converting

前端 未结 3 484
傲寒
傲寒 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条回答
  •  再見小時候
    2021-01-29 09:47

    from the GsonBuilder javadocs... you can use GsonBuilder to construct your Gson instance, and opt in to have null values serialized as so:

     Gson gson = new GsonBuilder()
         .serializeNulls()
         .create();
    

提交回复
热议问题