I am experimenting in combining Jackson and Lombok. Those are my classes:
package testelombok;
import com.fasterxml
I struggled with this for a moment as well. But looking through the documentation here I can see that the onConstructor annotation parameter is considered experimental and is not supported well on my IDE (STS 4). According to the Jackson documentation, private members are not (de)serialized by default. There are quick ways to resolve this.
Add JsonAutoDetect annotation and set it appropriately to detect protected/private members. This is convenient for DTOs
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
public class SomeClass
Add a factory function with @JsonCreator annotation, this works best if you need some object validation or additional transforms.
public class SomeClass {
// some code here
@JsonCreator
public static SomeClass factory(/* params here dressing them in @JsonProperty annotations*/) {
return new SomeClass();
}
}
Of course you could just manually add the constructor in yourself also as well.