vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

Function embedNullable

Makes this nullable as if it is not a nullable to the serializer. Ignores the field completely when it is null.

EmbedNullableIgnoreNullAttribute!Policy embedNullable(alias Policy)() @property;

Works with Nullable!classes and Nullable!structs. Behavior is undefined if this is applied to other types.

Implicitly marks this as optional for deserialization. (Keeps the struct default value when not present in serialized value)


import std.typecons : Nullable;

struct Test {
	// Not serialized at all if null, ignored on deserialization if not present.
	@embedNullable Nullable!int field;

Sönke Ludwig


© 2013-2016 rejectedsoftware e.K.


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.