Search code examples
javajbossjacksonjax-rsresteasy

How globally ignore Null Fields with restesy response?


I use JBoss EAP 7.1 with JAVA EE. I can exclude null fields in response using @JsonInclude(JsonInclude.Include.NON_NULL) annotation under class all filed. Does exist way to exclude globally (in all project) null values in all objects that resteasy return in response, for example here :

Response.status(Response.Status.OK).entity(objet).build()

Solution

  • You need to configure ObjectMapper instance in your app:

    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(Include.NON_NULL);
    

    See also: