annotation class JsonProperty(val name: String)(source)

Can be added to a data class property or enum instance to specify the name that is used when serializing it to and from JSON.

This is useful when integrating with an API that uses snake_case for example.

Using this is equivalent to using the Json annotation with the benefit that this annotation can be stripped using code shrinkers because of its retention.


data class User(
@JsonProperty(name = "full_name")
val fullName: String,


Link copied to clipboard