title: How to convert JSON to C# classes?
body: <p>I have a complex JSON object that I want represent as C# class. I have a head start on the parent class called "Form", but how can I represent a collection for different types (see the "elements" object below)?</p>
  
  <p>Here is the JSON object:</p>
  
  <pre><code>{
      "action": "index.html",
      "method": "post",
      "elements":
  [
  {
      "type": "fieldset",
      "caption": "User information",
      "elements":
      [
          {
              "name": "email",
              "caption": "Email address",
              "type": "text",
              "placeholder": "E.g. user@example.com",
              "validate":
              {
                  "email": true
              }
          },
          {
              "name": "password",
              "caption": "Password",
              "type": "password",
              "id": "registration-password",
              "validate":
              {
                  "required": true,
                  "minlength": 5,
                  "messages":
                  {
                      "required": "Please enter a password",
                      "minlength": "At least {0} characters long"
                  }
              }
          },
          {
              "name": "password-repeat",
              "caption": "Repeat password",
              "type": "password",
              "validate":
              {
                  "equalTo": "#registration-password",
                  "messages":
                  {
                      "equalTo": "Please repeat your password"
                  }
              }
          },
          {
              "type": "radiobuttons",
              "caption": "Sex",
              "name": "sex",
              "class": "labellist",
              "options":
              {
                  "f": "Female",
                  "m": "Male"
              }
          }
      ]
  ]
  }
  </code></pre>
  
  <p>The class I have start looks like this:</p>
  
  <pre><code>public class Form
  {
      public Guid id
      {
          get;
          set;
      }
  
      public string action
      {
          get;
          set;
      }
  
      public string method
      {
          get;
          set;
      }
  
      public ??? elements
      {
          get;
          set;
      }
  
      public Form()
      {
  
      }
  }
  </code></pre>
  
  <p>How do I handle the "elements" property to get the desired JSON output?</p>
  
  <p>I am using WCF 4.0 with these atributes in the web.config: automaticFormatSelectionEnabled="false", defaultOutgoingResponseFormat="Json". Any help or ideas would be greatly appreciated.</p>