I have a Model object that needs converted to a JSON object for passing to a WebAPI and when I call the .toJSON method a valid JSON object is returned, but Dates are still in a Date format, which they are not being properly serialized to JSON. So I have for the meantime added a prototype method to the ObservableObject called toJSON2 that checks if the field being processed is a Date object to call the Date objects toJSON method which is a prototype method you guys created anyways. It would be nice though if this one condition to check if the field being processed is a Date to then convert to a JSON date could be added into your source code.
kendo.data.ObservableObject.prototype.toJSON2 =
function
() {
var
result = {}, value, field;
for
(field
in
this
) {
if
(
this
.shouldSerialize(field)) {
value =
this
[field];
if
(value
instanceof
kendo.data.ObservableObject || value
instanceof
kendo.data.ObservableArray) {
value = value.toJSON2();
}
else
if
(value
instanceof
Date) {
value = value.toJSON();
}
result[field] = value;
}
}
return
result;
}