[Retrofit] How to name a Retrofit property


Writing time : 2021-08-15 16:34:34

If you use the SerializedName annotation, you can set the key received from the server to the property when mapping JSON.

class LoginResponse{  
    @SerializedName("jwt-auth-token")  
    public String jwtAuthToken;     
}  


data class LoginResponse(  
    @SerializedName("jwt-auth-token")  
    val jwtAuthToken: String,  
)  
Next post

Other posts in the category