title: WebMethod returning class object as JSON automatically
body: <p>Can anyone explain me how ASP.NET handles the convertion from a class object to the JSON object in WebMethods?</p>
  
  <p>For example, you have following WebMethod which returns a <code>Person</code> object:</p>
  
  <pre><code>    [WebMethod]
      public static Person GetPerson()
      {
          Person p = new Person() 
          {
              Id = 1,
              Name = "Test"
          };
  
          return p;
      }
  </code></pre>
  
  <p>In my jQuery where i call the WebMethod I get a response which contains out of a json object.</p>
  
  <p>How did ASP.NET do this automatcally? Does it uses the <code>JavaScriptSerializer</code> class? </p>
  
  <p>Also you see a lot of examples of using JSON converters to convert your class object to a json object. Why is this? Is it because of the <code>JavaScriptSerializer</code> class it uses and its bad performance or... ?</p>