JsonProperty
isn\'t overriding the default name jackson gets from the getter. If I serialize the class below with ObjectMapper
and jackson I get
The problem was that I was using both the old and new jackson libraries
i.e. before I had
import org.codehaus.jackson.annotate.JsonProperty;
Which I had to change to below, to be consistent with the library I was using.
Since I was using maven that also meant updating my maven dependencies.
import com.fasterxml.jackson.annotation.JsonProperty;
For it to work, I needed the @JsonProperty
annotation on the getter (putting it on the object didn't work)
I found the answer here (thanks to francescoforesti) @JsonProperty not working as expected