You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Rishi Agr <ri...@gmail.com> on 2022/02/28 10:25:41 UTC

Rest API does not send the null properties in response

Hi, I have observed that the response data from any API does not contain
the properties with null values. Upon having a check, I found that the
class "JacksonConfig" has
"objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);"
which excludes the null properties from the response data. Not sending the
null properties has benefits. But I feel that this property should be
configurable and not provide the feature of not sending the null
properties. It can be something like the default behavior is to not send
the null properties in the JSON response and it is configurable where the
developer can set some property to toggle the behavior. Please provide your
view on this and let me know if there is some configuration available and I
am missing something. Thank you.

Re: Rest API does not send the null properties in response

Posted by Michael Brohl <mi...@ecomify.de>.
Hi Rishi,

there is no configuration option currently.

We could either make this configurable or use 
JsonInclude.Include.USE_DEFAULTS to let the source class handle how null 
values will be rendered in the JSON.

As I am currently working on the plugin, please consider creating a Jira 
as a subtask for https://issues.apache.org/jira/browse/OFBIZ-11328 to 
discuss this further and track development.

Thanks and regards,

Michael Brohl

ecomify GmbH - www.ecomify.de


Am 28.02.22 um 11:25 schrieb Rishi Agr:
> Hi, I have observed that the response data from any API does not contain
> the properties with null values. Upon having a check, I found that the
> class "JacksonConfig" has
> "objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);"
> which excludes the null properties from the response data. Not sending the
> null properties has benefits. But I feel that this property should be
> configurable and not provide the feature of not sending the null
> properties. It can be something like the default behavior is to not send
> the null properties in the JSON response and it is configurable where the
> developer can set some property to toggle the behavior. Please provide your
> view on this and let me know if there is some configuration available and I
> am missing something. Thank you.
>