title: How to pass JSON data and convert to Object in WebSerivce
body: <p>I want to be able to convert a JSON object that is passed through ajax(jquery) in my webservice. At the moment I can get it to return the message "Hello World" but I don't know how to access the passed JSON data and then convert to a collection of type IList so I can iterate over the collection. I've had a look around on stackoverflow but I'm getting confused what to do can some one help me.</p>
  
  <p>Here is my code:</p>
  
  <p>jQuery:</p>
  
  <pre><code>var data = { dvals: [{'Name' : 'Acer', 'Count' : '2'}, {'Name' : 'HP', 'Count' : '4'} ] };
  
  function getProducts(json, pageIndex, pageSize) {
      json["PageIndex"] = pageIndex;
      json["PageSize"] = pageSize;
  
      $.ajax({
          type: 'POST',
          url: '/website2/WebServices/GetProducts.asmx/GetProductsAndFilters',
          data: JSON.stringify(json),
          contentType: 'application/json; charset=utf-8',
          dataType: 'json',
          success: function (responseText) {
              //alert(responseText.d);
              $('.console').html(responseText.d);
          },
          error: function (xhr, status, error) {
              //var msg = JSON.parse(xhr.responseText);
              //alert(msg.Message);
              $('.console').html(xhr.responseText)
          }
      });
  }
  getProducts(data, '0', '2');
  </code></pre>
  
  <p>My asp.net C#:</p>
  
  <pre><code>public class Filter
  {
      public string Name;
      public int Count;
  }
  public class Product
  {
      public int Id;
      public string Title;
      public string ShortDescription;
      public string Brand;
      public string Model;
      public double SellPrice;
      public string DescountPercentage;
      public int Votes;
      public int TotalRating;
      public double Rating
      {
          get
          {
              return Votes / TotalRating;
          }
      }
  }
  
  public class FiltersAndProducts
  {
      List&lt;Filter&gt; Filters;
      List&lt;Product&gt; Products;
      int PageIndex;
      int PageSize;
  }
  
  [WebMethod]
  [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  public string GetProductsAndFilters()
  {        
      return "Hello World";
  }
  </code></pre>