I want to make a post request with different naming of the JSON keys in Ktor and django. It is not a big deal but I want to follow the convention of naming the vals in Kotlin and django.
This is how my user post request body looks in Kotlin/Ktor:
@Serializable
data class UserPostRequest(
val username: String,
val email: String,
val password: String,
val password_check: String
)
The problem with this on is the "password_check" val, which is not named by convention
Property name 'password_check' should not contain underscores
When I try to change it to passwordCheck, make post request, it returns me an error that the passwords do not match.
I assumed this is because django expects 'password_check' as a JSON key.
You can use the SerialName annotation to override the name of the key:
@Serializable
data class UserPostRequest(
val username: String,
val email: String,
val password: String,
@SerialName("password_check")
val passwordCheck: String
)