Include Null or Empty Attributes in Response of Jax-Rs Rest Service
By Default when the response has empty or null attributes it is removed from the response structure to reduce payload size and to improve performance. But there are times when a complete structure is needed despite its attributes having a null or empty value. Below process shows how to modify a Jax-Rs application to include null or empty attributes in response structure. Create a sample Jax-Rs Application Create a basic Jax-Rs Application Add another param (param3) to both request and response structure and create a pojo class for the same Request: Response : Now in Sample Rest service add logic to map the Request param3 attribute to Response param3 attribute, this way we can test the Service by passing null as input parameters to check the response In most of the cases this is what may be expected but in some cases we may want to have all attributes as part of response despite having a null value. For...