I have a problem, I don't seem to know how to serialize a object of type:
public class SchedulingCalendarMonth
{
public List<SchedulingCalendarWeek> Weeks {get; set; }
}
public class SchedulingCalendarWeek
{
public List<SchedulingCalendarDay> Days { get; set; }
}
public class SchedulingCalendarDay
{
public int Id { get; set; }
public bool SomeBoolProperty { get; set; }
}
I've tried something like this:
<script type="text/javascript">
$(document).ready(function () {
var Month =
{
Weeks: []
};
var Weeks = { Days: [{ Id: 1, SomeBoolProperty: true }, { Id: 4, SomeBoolProperty: true }, { Id: 43, SomeBoolProperty: false}] };
Month.Weeks = Weeks;
$.ajax({
url: '/Home/Test',
type: 'POST',
dataType: 'json',
data: JSON.stringify({ month: Month }),
contentType: 'application/json; charset=utf-8',
success: function (result) {
alert(result.Result);
}
});
});
But all i get on the controller action is Month object with Weeks = null.
Any ideas?