title: JavaScriptSerializer : Unable to deserialize object containing HashSet field
body: <p>I am trying to deserialize an instance of the following class from a JSON string using JavaScriptSerializer:</p>
  
  <pre><code>public class Filter
  {
      public HashSet&lt;int&gt; DataSources { get; set;  }
  }
  </code></pre>
  
  <p>Here is the code I am trying out:</p>
  
  <pre><code>        Filter f = new Filter();
  
          f.DataSources = new HashSet&lt;int&gt;(){1,2};
  
          string json = (new JavaScriptSerializer()).Serialize(f);         
  
          var g= (new JavaScriptSerializer()).Deserialize&lt;Filter&gt;(json);
  </code></pre>
  
  <p>It errors out with the following message:</p>
  
  <blockquote>
    <p>Object of type 'System.Collections.Generic.List<code>1[System.Int32]'
    cannot be converted to type
    'System.Collections.Generic.HashSet</code>1[System.Int32]'.</p>
  </blockquote>
  
  <p>Apparently, the serializer is unable to distinguish between a list and set from JSON representation. What is the solution to this?</p>
  
  <p>Note : I would prefer avoiding the use of external libraries due to constraints at work.</p>