I have a class as follows, wrapping array of bytes:
public final class Plan {
private byte[] bytes;
private int peekIdx;
public Plan(byte[] bytes, int peekIdx) {
this.bytes = bytes;
this.peekIdx = peekIdx;
}
public Plan(byte[] bytes) {
this(bytes, 0);
}
//bunch more methods
}
This is contained in other objects as
public final class Agent {
private Plan plan;
//bunch more properties...
}
Now I want to deserialize a JSON like
{"plan": [0, 1, 2]}
as an Agent. However I can't figure out how to annotate Plan to achieve this. If it was just byte[] there wouldn't be an issue as this would correspond directly to a named property in Agent that can be put as @JsonProperty("plan"), but I somehow need to tell Jackson how to wrap the array in a Plan object. How to achieve this? Does it really require a custom serializer?