title: ASP.NET MVC 4 JSON Binding to the View Model - Nested object error
body: <p>I have got the problem with json binding to the view model. Here is my code:</p>
  
  <p>part of my ViewModels (AddressViewModel has more properties):</p>
  
  <pre><code>public class AddressViewModel
  {
          [Display(Name = "Address_Town", ResourceType = typeof(Resources.PartyDetails))]
          public string Town { get; set; }
  
          [Display(Name = "Address_Country", ResourceType = typeof(Resources.PartyDetails))]
          public Country Country { get; set; }
  }
  
  public class Country : EntityBase&lt;string&gt;
  {
          public string Name { get; set; }
  
          protected override void Validate()
          {
              if (string.IsNullOrEmpty(Name))
              {
                  base.AddBrokenRule(new BusinessRule("CountryName", "Required"));
              }
          }
  }
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>$(document).on("click", "#addAddress", function () {
              var jsonData = {
                  "Town": $('#txt-Town').val(),
                  "District": $('#txt-District').val(),
                  "Street": $('#txt-Street').val(),
                  "PostCode": $('#txt-PostCode').val(),
                  "FlatNumber": $('#txt-FlatNumber').val(),
                  "PremiseName": $('#txt-PremiseName').val(),
                  "PremiseNumber": $('#txt-Premisenumber').val(),
                  "Country": {
                      "Name": $('#txt-Country').val(),
                  }
              };
              var addressData = JSON.stringify(jsonData);
              $.ajax({
                  url: '/Customer/SaveAddress',
                  type: "POST",
                  dataType: "json",
                  contentType: "application/json; charset=utf-8",
                  data: addressData,
                  success: function (result) {
                      $("#addIndividualAddressDialog").data("kendoWindow").close();
                  },
                  error: function (result) {
                      alert("Failed");
                  }
  
              });
          });
  </code></pre>
  
  <p>Header of controller:</p>
  
  <pre><code>[HttpPost]
   public ActionResult SaveAddress(AddressViewModel addressViewModel)
  </code></pre>
  
  <p>This is what I see with firebug:</p>
  
  <p><img src="https://i.stack.imgur.com/JD27a.png" alt="enter image description here"></p>
  
  <p>And this is what I see in VS:</p>
  
  <p><img src="https://i.stack.imgur.com/GJwyQ.png" alt="enter image description here"></p>
  
  <p>As you can see Plain properties are binded correct but my nested object (Country) is null. I read a lot of different articles and I still don't know what I'm doing wrong. Help me please!</p>