title: how to deserialize jqgrid multiple group search criteria in asp .net mvc2
body: <p>If multiple grouping is used, jqgrid advanced search can generate search criteria like</p>
  
  <pre><code>{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":"kk"},{"field":"Nimi","op":"cn","data":"kkk"}],"groups":[]}]}
  </code></pre>
  
  <p>Trying to de-serialize it in ASP .NET MVC2 using</p>
  
  <pre><code>            var serializer = new JavaScriptSerializer();
              var filtersList = serializer.Deserialize&lt;Filter&gt;(_filters);
  
  
  class Filter
  {
      public GroupOp groupOp { get; set; }
      public List&lt;Rule&gt; rules { get; set; }
      public List&lt;Filter&gt; groups { get; set; }
  }
  
  class Rule
  {
      public string field { get; set; }
      public Operations op { get; set; }
      public string data { get; set; }
  }
  
  enum GroupOp
  {
      AND,
      OR
  }
  
  enum Operations
  {
      eq, // "equal"
      ne, // "not equal"
      lt, // "less"
      le, // "less or equal"
      gt, // "greater"
      ge, // "greater or equal"
      bw, // "begins with"
      bn, // "does not begin with"
      @in, // "in"
      ni, // "not in"
      ew, // "ends with"
      en, // "does not end with"
      cn, // "contains"
      nc  // "does not contain"
  }
  </code></pre>
  
  <p>returns empty filtersList.rules property</p>
  
  <p>How to get correct rules from this data ?</p>
  
  <p><strong>update</strong></p>
  
  <p>filter</p>
  
  <pre><code>    {"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":""},
  {"field":"Nimi","op":"cn","data":""},{"field":"Nimi","op":"cn","data":""}],
  "groups":[{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":
  [{"field":"Nimi","op":"cn","data":""}],"groups":[{"groupOp":"AND","rules":[],
  "groups":[{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[],
  "groups":[{"groupOp":"AND","rules":[],"groups":[{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]}]}]}]}]},{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":""}],"groups":[{"groupOp":"AND","rules":[{"field":"Nimi","op":"cn","data":""},{"field":"Nimi","op":"cn","data":""}],
  "groups":[]}]},{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]},{"groupOp":"AND","rules":[],"groups":[]}]}]}]}
  </code></pre>
  
  <p>using code from updated part in referenced answer still generates invalid where</p>
  
  <pre><code>    ((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!')AND(klient.Nimi ILIKE
   ('%' || E'' || '%') ESCAPE '!')AND(klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))AND
  ((((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))AND(((((())))AND(((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))AND(((klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!')
  AND(klient.Nimi ILIKE ('%' || E'' || '%') ESCAPE '!'))))))))
  </code></pre>