Question
cannot deserialize from Object value (no delegate- or property-based Creator) even with default constructor present
I have a class that looks like
class MyClass {
private byte[] payload;
public MyClass(){}
@JsonCreator
public MyClass(@JsonProperty("payload") final byte[] payload) {
this.payload = payload;
}
public byte[] getPayload() {
return this.payload;
}
}
I am using Jackson so serialize and then to deserialize. Serialization works fine, but during deserialization, I am getting this error message -
Cannot construct instance of `mypackage.MyClass` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
I was reading about this problem online, and came across several texts recommending to have a default constructor or a constructor with @JsonCreator
annotation. I tried adding both, but still getting that exception. What am I missing here?