On Sunday, 24 May 2020 at 12:37:20 UTC, ag0aep6g wrote:
On 24.05.20 14:29, bauss wrote:
Dang, that sucks there is no proper way and I would say that's a big flaw of D.

Because what I need it for is for some data serialization but if the value is an empty array then it should be present and if it's null then it should not be present.

Since null is used to say "ignore this" in the data serialization.

You can use std.typecons.Nullable (or a similar wrapper) to add an extra "ignore this" value to a type.

and just in case you use vibe.d serialization (JSON, BSON or other custom ones), there is a new @embedNullable UDA which treats Nullable!T inside a map as a T or completely omits it if it's null ;)

Reply via email to