kamikat / moshi-jsonapi

JSON API v1.0 Specification in Moshi.
MIT License
156 stars 35 forks source link

@Json is not serializing variable name when making a Retrofit GET Request with a body. #114

Closed GitDoGui closed 3 years ago

GitDoGui commented 3 years ago

I need to make a GET JSON API request with the following object inside data. When the request is made, new_password and new_password_confirmation are beeing sent as newPassword and newPasswordConfirmation. @Json(name) annotation is not working. Is this only for received jsons?

@JsonApi(type = "password_update")
data class UpdatePasswordDTO(
    @Json(name = "password") val password: String?,
    @Json(name = "new_password") val newPassword: String?,
    @Json(name = "new_password_confirmation") val newPasswordConfirmation: String?
) : Resource() {
    constructor() : this(null, null, null, null)
}
GitDoGui commented 3 years ago

Issue solved. Used @field:Json(name...) Instead of @Json(name...)