Reputation: 13453
Using the MongoDB C# driver, the following code gives me { }
in the json
variable. It seems to ignore the null value in its serialization.
var document = new BsonDocument{{"x", null}};
var json = document.ToJson();
However I want json
to be { "x": null }
. Can I set some option for it to serialize null values?
Upvotes: 0
Views: 1840
Reputation: 1789
Somebody else asked something similar here
Basically, you have to use BsonNull.Value
.
Upvotes: 2