I have a json object with a lot of properties (~80 properties) I want to deserialize in a POJO without creating manually all the properties. I was able to do this by using the @JsonAnySetter with a Map property like described here.
Now I want to make this work by making my POJO immutable using Lombok.
I tried this but it does only deserialize the id and code properties. Any idea on how to make it work?
@Value
@Builder
@EqualsAndHashCode
@JsonDeserialize(builder = Product.ProductBuilder.class)
class Product {
@JsonProperty
private String id;
@JsonProperty
private String code;
@Getter(AccessLevel.NONE)
@Builder.Default
@JsonProperty
private Map<String, Optional<Object>> any = new HashMap<>();
@JsonAnyGetter
public Map<String, Optional<Object>> getAny(){
return this.any;
}
@JsonAnySetter
public void setAny(String key, Optional<Object> value){
this.any.put(key, value);
}
}