serializeValue

Nullable type serialization

Examples

import std.typecons;

struct Nested
{
    float f;
}

struct T
{
    string str;
    Nullable!Nested nested;
}

T t;
assert(t.serializeToJson == `{"str":null,"nested":null}`);
t.str = "txt";
t.nested = Nested(123);
assert(t.serializeToJson == `{"str":"txt","nested":{"f":123.0}}`);

Meta