title: C# Json.NET Render Flags Enum as String Array
body: <p>In a .NET Application, I have a set of values that are stored as a <code>[Flags] enum</code>. I want to serialize these to json, but instead of having the result be an integer, I'd like to get an array of string for the flags that are active.</p>
  
  <p>So if I have the following code </p>
  
  <pre><code>[Flags]
  public enum F
  {
      Val1 = 1,
      Val2 = 2,
      Val4 = 4,
      Val8 = 8
  
  }
  
  public class C
  {        
      public F Flags { get; set; }
  }
  
  string Serialize() {
      return JsonConvert.SerializeObject(new C { Flags = F.Val1 | F.Val4 });
  }
  </code></pre>
  
  <p>I want the <code>Serialize()</code> method to return:</p>
  
  <pre><code>"{ Flags: [ "Val1", "Val4" ] }"
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>"{ Flags: 5 }"
  </code></pre>