I’ve a POJO which I want to ignore certain fields while ObjectMapper
deserialization at same time i want to have an @AllArgsConstructor
how can I annotate a certain field to make it work?
ex:
@NoArgsConstructor
@Getter
@Builder
@AllArgsConstructor
@Setter
public class C{
@JsonIgnore
private Board board;
@JsonProperty(value = "title")
private String title;
@JsonProperty(value = "position")
private int position;
}
it will fail if i do:
objectMapper.readValue("{"title":"title","position":2}",C.class);
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Invalid type definition for type `C`: Argument #0 of constructor [constructor for `C` (3 args), annotations: [null] has no property name annotation; must have name when multiple-parameter constructor annotated as Creator
at [Source: (String)"{"title":"title","position":2}"; line: 1, column: 1]
but if i add
@JsonProperty("blablabla")
private Board board;
then the above code works
i would like to tell jackson to ignore that property while keeping all args constructor
2