title: JavaScriptSerializer with custom Type
body: <p>I have a function with a List return type. I'm using this in a JSON-enabled WebService like:</p>
  
  <blockquote>
  <pre><code>  [WebMethod(EnableSession = true)]
      [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
      public List&lt;Product&gt; GetProducts(string dummy)  /* without a parameter, it will not go through */
      {
          return new x.GetProducts();
      }
  </code></pre>
  </blockquote>
  
  <p>this returns:</p>
  
  <pre><code>{"d":[{"__type":"Product","Id":"2316","Name":"Big Something ","Price":"3000","Quantity":"5"}]}
  </code></pre>
  
  <p>I need to use this code in a simple aspx file too, so I created a JavaScriptSerializer:</p>
  
  <pre><code>        JavaScriptSerializer js = new JavaScriptSerializer();
          StringBuilder sb = new StringBuilder();
  
          List&lt;Product&gt; products = base.GetProducts();
          js.RegisterConverters(new JavaScriptConverter[] { new ProductConverter() });
          js.Serialize(products, sb);
  
          string _jsonShopbasket = sb.ToString();
  </code></pre>
  
  <p>but it returns without a type:</p>
  
  <pre><code>[{"Id":"2316","Name":"Big One ","Price":"3000","Quantity":"5"}]
  </code></pre>
  
  <p>Does anyone have any clue how to get the second Serialization work like the first?</p>
  
  <p>Thanks!</p>