Reputation: 1920
I have an object
data class FileInformation(
@SerializedName("filename")
val fileName: String,
@SerializedName("filesize")
val fileSize: Long,
@SerializedName("filedate")
val fileDate: String,
var status: Int = FILE_PENDING)
There are times that i want to serialize the above class WITH the status field but other times WITHOUT the status field. How can i do that??
Upvotes: 1
Views: 1931
Reputation: 590
You might be looking for Exclusion Strategies - Look at the following link to the GSON documentation for further details: https://howtodoinjava.com/gson/gson-exclude-or-ignore-fields/ :)
Upvotes: 1