title: Custom Serialization using Attributes and ServiceStack.Text.JsonSerializer
body: <p>We use custom attributes to annotate data how it should be displayed:</p>
  
  <pre><code>public class DcStatus
  {
      [Format("{0:0.0} V")]   public Double Voltage { get; set; }
      [Format("{0:0.000} A")] public Double Current { get; set; }
      [Format("{0:0} W")]     public Double Power =&gt; Voltage * Current;
  }
  </code></pre>
  
  <p>The properties are processed with <code>String.Format</code> using the format provided by the attribute.  </p>
  
  <p>How do we need to configure <code>ServiceStack.Text.JsonSerializer</code> to use that attribute too?</p>
  
  <p>Example:</p>
  
  <pre><code>var test = new DcStatus {Voltage = 10, Current = 1.2};
  var json = JsonSerializer.SerializeToString(test);
  </code></pre>
  
  <p>should produce</p>
  
  <pre><code>{
      "Voltage": "10.0 V",
      "Current": "1.200 A",
      "Power"  : "12 W",
  }
  </code></pre>