title: Serializing a list of enums in Json.net
body: <p>I have a solution in which I'm needing to convert a number of C# classes into their JSON format for a REST API. I'm using enums to avoid having to remember the strings to pass in for values when an enum would suffice.</p>
  
  <p>To that end, one of the arguments is a List of enums. As I already have a class written using the JsonConverter, I thought I'd just pass this list of enums along to the WriteJson method as I would just a plain enum and it'd just automatically handle the list component of it behind the scenes somewhere. Unfortunately, this isn't the case. In my WriteJson method, I have the following:</p>
  
  <pre><code>public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) {
    var e = (SuiteType) value;
    switch (e) {
      case SuiteType.Full:
        writer.WriteValue("complete");
        break;
      case SuiteType.Partial:
        writer.WriteValue("partial");
        break;
    }
  }
  </code></pre>
  
  <p>This gives the error about a bad cast when I try to cast it to the SuiteType because of course the inbound value is actually a List of SuiteType and not just a SuiteType. With that in mind, how could I handle this custom conversion (since it's not always a 1:1 between the enum names and the string or int values they'd output while still converting from a collection of such enums?</p>