title: How to parse Dictionary type with json-ajax
body: <p>I have Dictionary which will return from server, i converted it json string format as below:</p>
  
  <pre><code>public static class Extensions 
  { 
      public static string ToJson&lt;T&gt;(this T obj) 
      { 
          MemoryStream stream = new MemoryStream(); 
          try { 
              DataContractJsonSerializer jsSerializer = new DataContractJsonSerializer(typeof(T)); 
              jsSerializer.WriteObject(stream, obj); 
  
              return Encoding.UTF8.GetString(stream.ToArray()); 
          } 
          finally 
          { 
              stream.Close(); 
              stream.Dispose();
          } 
      } 
      public static T FromJson&lt;T&gt;(this string input) 
      { 
          MemoryStream stream = new MemoryStream();
          try {
              DataContractJsonSerializer jsSerializer = new DataContractJsonSerializer(typeof(T));
              stream = new MemoryStream(Encoding.UTF8.GetBytes(input)); 
              T obj = (T)jsSerializer.ReadObject(stream); return obj; 
          } 
          finally 
          { 
              stream.Close(); 
              stream.Dispose();
          }
      } 
  }
  
  [WebMethod]
  public string callme()
  {
      Dictionary&lt;int, string&gt; myObjects = new Dictionary&lt;int, string&gt;();
      myObjects.Add(1, "This");
      myObjects.Add(2, "is");
      myObjects.Add(3, "cool");
      string json = myObjects.ToJson();
      return json;
  }
  </code></pre>
  
  <p>so Result is:</p>
  
  <pre><code>{"d":"[{\"Key\":1,\"Value\":\"This\"},{\"Key\":2,\"Value\":\"is\"},{\"Key\":3,\"Value\":\"cool\"}]"}
  </code></pre>
  
  <p><strong>How I parse that in jquery? I m trying this but not help</strong></p>
  
  <pre><code>$.ajax({
        type: "POST",
        url: "web.asmx/callme",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg){
            $.each(msg.d, function (i) {
            $("#data2").append(i.Key + " " + i.Value + "&lt;br/&gt;");
          });
        }
      });
  </code></pre>