title: How to deserialize interfaces with Newtonsoft Json.Net
body: <p>I have this class hierarchy :</p>
  
  <pre><code>public class ProxyBotsSnapshotLogEntryDetails : IBotsSnapshotLogEntryDetails
  {
      public ICollection&lt;IBotSnapshot&gt; Snapshots { get; set; }
  }
  public class ProxyBotSnapshot : IBotSnapshot
  {
      public string Name { get; set; }
      public ICollection&lt;IBotSnapshotItem&gt; States { get; set; }
  }
  
  public class ProxyBotSnapshotItem : IBotSnapshotItem
  {
      public int Count { get; set; }
      public IrcBotChannelStateEnum State { get; set; }
  }
  </code></pre>
  
  <p>and their corresponding interfaces</p>
  
  <pre><code>public interface IBotsSnapshotLogEntryDetails
  {
      ICollection&lt;IBotSnapshot&gt; Snapshots { get; set; }
  }
  
  public interface IBotSnapshot
  {
      string Name { get; set; }
      ICollection&lt;IBotSnapshotItem&gt; States { get; set; }
  }
  
  public interface IBotSnapshotItem
  {
      int Count { get; set; }
      IrcBotChannelStateEnum State { get; set; }
  }
  </code></pre>
  
  <p>that I would like to deserialize from JSON:</p>
  
  <pre><code>var test = JsonConvert.DeserializeObject&lt;ProxyBotsSnapshotLogEntryDetails&gt;(entry.DetailsSerialized);
  </code></pre>
  
  <p>but I get an error saying that Newtonsoft cannot convert interfaces.</p>
  
  <p>I found this promising article:</p>
  
  <blockquote>
    <p><a href="https://www.c-sharpcorner.com/UploadFile/20c06b/deserializing-interface-properties-with-json-net/" rel="noreferrer">https://www.c-sharpcorner.com/UploadFile/20c06b/deserializing-interface-properties-with-json-net/</a></p>
  </blockquote>
  
  <p>but am not sure how to use the attribute, since in my case, the property is a list of interface.</p>