vibe.d beta banner
get vibe.d
0.10.1

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)

Example

import std.typecons : Nullable;

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

Sönke Ludwig

Copyright

© 2013-2016 rejectedsoftware e.K.

License

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