title: How to properly structure C# nested classes to receive complex JSON
body: <p>I am passing JSON object back to a C# aspx page web method.</p>
  
  <p>My JavaScript looks like:</p>
  
  <pre><code> return jsonItem = {
                       id: id,
                       title:  title,
                       registrationPage: {
                          registration: registration                              
                       }                                                  
                     }
  </code></pre>
  
  <p>I am passing this item to an aspx web method:</p>
  
  <pre><code>$.ajax({
            type: "POST",
            url: "SaveXML.aspx/SaveAs",
            data: JSON.stringify({ jsonItem : jsonItem }),
            contentType: "application/json; charset=utf-8",                
            dataType: "json",
            success: function (msg, textStatus) {
                  alert(textStatus);
            },
      });
  </code></pre>
  
  <p><strong>The JSON payload is being sent fine</strong>.</p>
  
  <p>In the aspx page I have the classes:</p>
  
  <pre><code>public class JSONItem
  {
      public string Id { get; set; }
      public string Title { get; set; }  
      public RegistrationPage RegistrationPage { get; set; }           
  }
  
  public class RegistrationPage
  {
       public string Registration { get; set; }
  }
  
  [WebMethod]
  public static Policy Save(Policy policy)
  {
  }
  </code></pre>
  
  <p>When I try building this I get a code analysis error, which makes sense:</p>
  
  <blockquote>
    <p>CA1034 : Microsoft.Design : Do not nest type  'SaveXML.RegistrationPage'. Alternatively,  change its accessibility so that it is not externally visible.</p>
  </blockquote>
  
  <p><strong>If I ignore the error, the code does work. I did try changing the modifiers but then the Registration Page object wasn't populated.</strong> </p>
  
  <p>How do I get the code to work and comply with the above error?</p>
  
  <p>Thanks</p>