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