title: JSON Array is null when passed to MVC Rest interface
body: <p>I am attempting to pass a JSON object that contains both generic string properties and an array of objects with properties. </p>
  
  <p>The Model Object:</p>
  
  <pre><code>public class Stock
  {
      public IEnumerable&lt;Daily&gt; DailyList;
      public string Symbol { get; set; }
      public double PERatio { get; set; }
  }
  
  public class Daily
  {
      public double EndOfDayPrice { get; set; }
      public int Volume { get; set; }
      public double DayDiff { get; set; }
  }
  </code></pre>
  
  <p>The following is my HomeController code:</p>
  
  <pre><code>public class HomeController : Controller
  {
      public ActionResult Index()
      {
          return View();
      }
  
      public JsonResult Dump()
      {
          Stock s = new Stock()
          {
              Symbol = "YHOO",
              PERatio = 4.31,
              DailyList = new List&lt;Daily&gt;()
              {
                  new Daily {EndOfDayPrice = 4.13, DayDiff = 1.2, Volume = 15000 },
                  new Daily {EndOfDayPrice = 4.1, DayDiff = .5, Volume = 1300 }
              }
          };
  
          return Json(s, JsonRequestBehavior.AllowGet);
      }
  
      [HttpPost]
      public JsonResult ProcessDataReturned(Stock stock)
      {
          stock = stock;
          // int count = mylist.Length;
          return Json("success");
      }
  }
  </code></pre>
  
  <p>This is my JavaScript on my page:  </p>
  
  <pre><code>function calculate(pricelist) {
      var count = 1; //skip first;
      var teststring = { "DailyList": [{ "EndOfDayPrice": 4.13, "Volume": 15000, "DayDiff": 1.2 }, { "EndOfDayPrice": 4.1, "Volume": 1300, "DayDiff": 0.5 }], "Symbol": "YHOO", "PERatio": 4.31 };
  
      $.post("/home/ProcessDataReturned/", teststring).done(function (data2) { document.write(data2 + "&lt;hr&gt;"); });
      //Tried with the JSON.stringify also.
      $.post("/home/ProcessDataReturned/", JSON.stringify(teststring)).done(function (data2) { document.write(data2 + "&lt;hr&gt;"); });
  }
  </code></pre>
  
  <p>When I go to the controller and watch the value coming over the array of DailyList is always null.  The other properties are fine. I have tried to make the Model(C#) to use both IList and IEnumerable for the property.</p>
  
  <p>NEW CODE as suggested by contributors. I am still having the same problem.  Array is still empty (not null because I initialize it in the constructor).</p>
  
  <pre><code>    var x = JSON.stringify({ stock: teststring });
      //Other variations I have tried
      //var x = JSON.stringify(teststring);
  
      $.ajax({
          url: '@Url.Action("ProcessDataReturned", "home")',
          data: x,
          type: 'POST',
          traditional:true,
          contentType: "application/json; charset=utf-8",
          success: function (data) {
              $('#message').html("Reason was updated");}
      });
  </code></pre>
  
  <p>Solution: Because there were actually multiple pieces wrong I gave credit to each person.  Additionally I found one bug on my own. 
  1. I must use the long form version of the ajax call.  ie use $.ajax instead of $.post
  2. My model on the server was not set up correctly.  I needed to add the "{get;set;}" to the property declaration for the list. Silly mistake on my part and the code below enabled me to see that issue.
      public class Stock
      {
          //public IEnumerable DailyList;
          //Change this to this (Stupid Mistake):
          public IEnumerable DailyList {get;set;};
          public string Symbol { get; set; }
          public double PERatio { get; set; }
      }</p>