I am trying to filter out the API endpoint response using the Jackson library.
I can use @JsonFilter ("[filterNameHere]"), but this ends with a class expecting the filter to be applied every time.
Is there a way to filter the response on only one specific instance?
Pizza pizza = pizzaService.getPizzaById(pizzaId);
ObjectMapper mapper = new ObjectMapper();
FilterProvider filters = new SimpleFilterProvider().addFilter("baseFilter", SimpleBeanPropertyFilter.serializeAllExcept("base"));
String json = mapper.writer(filters).writeValueAsString(pizza);
return Response.status(200).entity(json).build();
I tried to look back, but could not find anything suitable.
source
share