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 th
Use transient keywork for that
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 transient String pName; //Have not to send to server
//@Expose(serialize = false , deserialize = false)
private transient String pPrice; //Have not to send to server
//@Expose(serialize = false , deserialize = false)
private transient String pImageUrl; //Have not to send to server
}
and no need to use @Expose(serialize = false , deserialize = false)
, into those fields which needed to be excluded.
Read Why does Java have transient fields? and Why use the `transient` keyword in java? for more details.