Skip to content
This repository has been archived by the owner. It is now read-only.

Set JSON NullValueHandling to Ignore by default #4284

Closed
khellang opened this issue Mar 14, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@khellang
Copy link
Contributor

commented Mar 14, 2016

From #4283:

I'd like to propose setting NullValueHandling to Ignore by default. It's just a waste of bytes, IMO.

I assume that a high percentage of JSON returned from an API is consumed by JavaScript, where both null and undefined are falsy, so if (json.someProperty) { /* do something */ } would have the same results, whether the property is null or just absent.

It should also be no problem if the consumer is using Newtonsoft.Json, where MissingMemberHandling is set to Ignore by default. This would simply set missing properties to default(T).

@glennblock

This comment has been minimized.

Copy link

commented Mar 14, 2016

Agreed. Another annoyance that I constantly have to override.

@Eilon Eilon added this to the Backlog milestone May 26, 2016

@Eilon

This comment has been minimized.

Copy link
Member

commented May 26, 2016

We discussed at length with @danroth27 and also @JamesNK and ultimately concluded that we feel this isn't an entirely safe change to make. The concern is that for some scenarios there is a significant difference between a key that is present, but with a null value, and no key at all. While it's certainly nice to trim down on the size of the serialized data, this carries with it a significant semantic change, and it's one that we feel is too risky to make in the general case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.