I want to annotate with @JsonCreator using a primary constructor, something like this:
// error
@JsonCreator class User(
@JsonProperty("username") var username: String,
@JsonProperty("password") var password: String
) {
// ...
}
But the @JsonCreator annotation gives an error "This annotation is not applicable to target 'class'".
Using a secondary constructor works, but is it the only (or best) way?:
// works, but is there a better way?
class User @JsonCreator constructor(
@JsonProperty("username") var username: String,
@JsonProperty("password") var password: String
) {
// ...
}