Reputation: 9404
I have a data class with the following code
data class MyBody(
@SerializedName("ver") val version: Int,
@SerializedName("TO") val methodName: String,
@SerializedName("JR") val jsonParams: String)
now I need to add a new SerializedName which is "type" the problem that this new parameter should only be used in some methods not all of them
can anyone please advice ?
Upvotes: 1
Views: 2571
Reputation: 2853
You have to use nullable operator. Example:
import com.google.gson.annotations.SerializedName
data class RouteGroup @JvmOverloads constructor(
@SerializedName("name") var name: String? = null,
@SerializedName("id") var id: Int? = null
)
Upvotes: 4