Data class的Moshi/Gson实现方式:
2021-01-28 本文已影响0人
Sarah_love
1.GSON解析:
import com.google.gson.annotations.SerializedName
public class ScheduleMessagesRequest {
@SerializedName("wedding_id")
public StringweddingId;
@SerializedName("member_id")
public StringmemeberId;
@SerializedName("sequence_id")
public StringsequenceId;
}
2. Moshi解析:
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
@JsonClass(generateAdapter = true)
data class PasswordPayload(
@Json(name = "email")
var email: String? =null,
@Json(name = "password")
var password: String? =null,
@Json(name = "new_password")
var newPassword: String? =null,
@Json(name = "new_password_confirmation")
var confirmPassword: String? =null)