import std.conv; // represented as a string when serialized static struct S { int value; // dummy example implementations string toString() const { return value.to!string(); } static S fromString(string s) { return S(s.to!int()); } } static assert(isStringSerializable!S);
vson.serialization.serializeWithPolicy
Checks if a given policy supports custom serialization for a given type.
A class or struct type is custom serializable according to a policy if the policy defines a pair of toRepresentation/fromRepresentation functions. Any class or struct type that has this trait for the policy supplied to $D(serializeWithPolicy) will be serialized by using the return value of the policy toRepresentation function instead of the original value.
This trait has precedence over isCustomSerializable, isISOExtStringSerializable and isStringSerializable.