I am porting my Java web application from a servlet to JAX-RS. Since I use Jboss, I will also use (default) RESTEasy.
In my servlets, I use Jackson to serialize / deserialize JSON; Jackson allows me to programmatically filter the inclusion / exclusion of fields, for example:
ObjectMapper mapper = new ObjectMapper().setVisibility(JsonMethod.FIELD, Visibility.ANY); String[] ignorableFieldNames = { "id", "name" }; FilterProvider filters = new SimpleFilterProvider(). addFilter("f123",SimpleBeanPropertyFilter.serializeAllExcept(ignorableFieldNames)); mapper.filteredWriter(filters).writeValueAsString(object);
RESTEasy provides Jackson support, but it seems to be transparently implemented by the developer, so I canβt switch to the low-level include / exclude fields. Is it possible?
source share