Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ads69 opened this issue Dec 2, 2020 · 1 comment
Closed

Comments

@ads69
Copy link

ads69 commented Dec 2, 2020

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

@danieleteti
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants