I have a simple Map and I would like to deserialize it to a Pojo with some internal nested classes.
Example for map:
Map = ["total_errs"=20, "err_1_day"=3, "err_2_day"=1, ..., "err_30_day=5"]
I would like to deserialize this into a nice Pojo as follow:
class CustomPojo {
@JsonProperty("total_errs")
private long totalErrors;
private List<ErrorByDay> errByDays;
static class ErrorByDay {
private long age; // age is the key of each map entry
private long count; // count is the value of each map entry
}
}
Calling code:
CustomPojo pojo = new ObjectMapper().convert(map, CustomPojo.class);
Is there a nice way to solve this using annotations only? (I know I can write a custom Deserializer for that).
Thank you!