如何忽略用于改造的模型中的某些变量 [英] How to ignore some variables in models using for retrofit
本文介绍了如何忽略用于改造的模型中的某些变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Retrofit 向我的服务器发送和接收请求.
I am using Retrofit to send and receive requests to my server.
我有一个如下所示的模型,我必须将其发送到服务器,但是此模型中的某些变量没有发送到服务器.
I Have a model like below and I have to send it to my server but some variables in this model have not to send to the server.
public class SelectedListModel implements Serializable {
@SerializedName("p_id")
@Expose
private Long pId;
@SerializedName("p_qty")
@Expose
private Double pQty;
@Expose(serialize = false , deserialize = false)
private String pName; //Have not to send to server
@Expose(serialize = false , deserialize = false)
private String pPrice; //Have not to send to server
@Expose(serialize = false , deserialize = false)
private String pImageUrl; //Have not to send to server
}
,因此,我从服务器得到的响应为400.
我使用@Expose(serialize = false, deserialize = false)
来忽略不必发送到服务器的变量.
但这是行不通的.
有什么方法可以做,还是我必须为我的服务器创建另一个模型?
and because of that, I am getting 400 in my responses from the server.
I used of @Expose(serialize = false, deserialize = false)
in order to Ignore variables that have not to send to the server.
But it doesn't work.
Is there any way to do this or I have to create another model just for my server?
推荐答案
查看全文