Is it allowed to have spaces in @JsonProperty name? i.e.
@JsonProperty("Jon Snow")
private String jonSnow = "Lord";
// getter & setter are omitted
I expect to get the following output:
{
"Jon Snow" : "Lord"
}
But the actual result is:
{
"jonSnow" : "Lord"
}
I use jackson-core v2.8.8, jackson-databind v2.8.8.1, and jackson-annotations v2.8.8.
The problem was that I was using @JsonProperty annotation from the wrong Jackson library.
I had import org.codehaus.jackson.annotate.JsonProperty; (Jackson v1) which I had to change to import com.fasterxml.jackson.annotation.JsonProperty; (Jackson v2), to be consistent with the library I was using.
I've found the answer in comments to this question: @JsonProperty not working as expected
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With