danieleteti / delphimvcframework

DMVCFramework (for short) is a popular and powerful framework for WEB API in Delphi. Supports RESTful and JSON-RPC WEB APIs development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(Nullable) Attribute for not serializing property or a field if it is Null

ads69 opened this issue · comments

commented

Hi,
When working with Nullable types it would be nice to have a new attribute to serialize only non null fields (or properties), empty arrays, null sub objects.
In this case the resulting json could be significantly reduced in size and reduce network bandwidth.
Best regards

Armindo

Yes, we considered this. However this would introduce an incongruency between serialization and deserialization. While deserializing a nullable field, in case of null that value is setted on the deserialized object (previous value is overwritten), while in case of empty property the value will remain the same. This is the reason because also null fields are serialized.