I am using Jersey 2.4 with spring.
When I am returning a response from a method with an annotation @Produces(MediaType.APPLICATION_JSON)
on it, it also serialize the null values to json.
I don't want to serialize the fields that contains the null values.
Is there any solution for the same?
Assuming, you are using Jackson for serialization, you can use the
@JsonInclude(Include.NON_NULL)
to your class to exclude the null values.