public static string Serialize(Money?instance) { string serialized; if (instance.HasValue) { var surrogate = new CanonicalSurrogate(instance.Value); serialized = JsonSerializer.SerializeToString(surrogate); } else { serialized = JsonSerializer.SerializeToString(instance); } return(serialized); }
public static string Serialize(Money instance) { var surrogate = new CanonicalSurrogate(instance); return(JsonSerializer.SerializeToString(surrogate)); }