JsonProperty
isn\'t overriding the default name jackson gets from the getter. If I serialize the class below with ObjectMapper
and jackson I get
If using Kotlin
I understand the original question is in Java, but since Kotlin is becoming very popular and many might be using it I'd like to post this here to help others.
Anyway, for Kotlin, because how getters/setters work, if you are using val
, meaning you only expose the getter, you may need to apply the annotation to the getter like below:
class JacksonTester(@get:JsonProperty("hello") val hi: String)