My class looks like this,
@Getter
@ToString
@EqualsAndHashCode
public class Clazz {
private String a;
private long b;
private CustomObject c;
private List<String> d;
@Builder
@JsonCreator
public Clazz(@JsonProperty(“a”) String a,
@JsonProperty(“b”) long b,
@JsonProperty(“c”) CustomObject c,
@JsonProperty(“d”) List<String> d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
}
I am getting issue while de-serialise CustomObject
. How can i write custom serialiser and De-serialiser just for CustomObject?
ObjectMapper that I am using for de-serialisation and serialisation,
objectMapper = spy(JsonMapper.builder()
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.addModule(new GuavaModule())
.addModule(new ParameterNamesModule())
.serializationInclusion(JsonInclude.Include.NON_NULL)
.activateDefaultTyping(ptv, ObjectMapper.DefaultTyping.NON_CONCRETE_AND_ARRAYS)
.build());
I cannot alter the CustomObject class, hence need to handle the serialisation/deserialisation here in this class only.
Thank you in advance.