samedi 4 novembre 2023

How can I skip fields of certain types during serialization?

I have a Spring AOP service which intercepts a lot of different third-party controllers endpoints. My service runs an endpoint, gets the result DTO, serialize DTO to json with ObjectMapper, sends json to Kafka and return the DTO outside. The problem is: the service shouldn't serialise fields of particular types (e.g MultipartFile). I can't use @JsonIgnore annotation, because DTO should be returned outside without changes. Can I make ObjectMapper skip fields of certain types? Or, maybe, copy the DTO and set this fields to null with reflection?





Aucun commentaire:

Enregistrer un commentaire