title: List of strings as CSV string in Json.Net
body: <p>I wonder if it is possible to serialize and deserialize any <code>List&lt;string&gt;</code> as a string of comma separated values in C# using Json.Net:</p>
  
  <pre><code>class MyDTO
  {
      public int Age { get; set; } = 25;
      public string Name { get; set; } = "Jon";
      public List&lt;string&gt; Friends { get; set; } = new List&lt;string&gt; {"Jan", "Joe", "Tim"};
  }
  
  var serilalized = JsonConvert.SerializeObject(new MyDTO());
  
  //serialized = { "name": "Jon", "age": 25, "friends": "Jan,Joe,Tim" }
  
  var deserialized = JsonConvert.DeserializeObject&lt;MyDTO&gt;(serialized);
  
  //deserialized.Name = "Jon", deserialized.Age = 25, deserialized.Friends = List&lt;string&gt; {"Jan", "Joe", "Tim"}
  </code></pre>
  
  <p>How could I achieve what the comments in the code reflect?</p>
  
  <p>Implementing a custom <code>JsonConverter</code> is a good solution to this problem, but when I deserialize using the non generic version <code>JsonConvert.DeserializeObject(serialized)</code>, the JsonConverter does not have effect and the deserialized value has type <code>JTokenType.String</code>, instead of <code>JTokenType.Array</code> that is the type that I want to get. For example:</p>
  
  <pre><code>JObject obj = (JObject)JsonConvert.DeserializeObject(serilalized);
  
  JToken token = obj["friends"];
  
  Console.WriteLine(token.Type == JTokenType.String); //prints true
  
  Console.WriteLine(token.Type == JTokenType.Array); //prints false
  </code></pre>
  
  <p>I would like that the code above could print <code>false</code> in the first case and <code>true</code> in the second. Note that while deserializating I don't have the type <code>MyDTO</code> available.</p>