When using:
var dataToSave = ko.toJSON(myViewModel);
.. is it possible to not serialize values that are null?
Seri
You can add a toJSON method to your view model and use that to remove all the unneeded properties:
ViewModel.prototype.toJSON = function() {
var copy = ko.toJS(this);
// remove any unneeded properties
if (copy.unneedProperty == null) {
delete copy.unneedProperty;
}
return copy;
}
You could probably automate it to run through all your properties and delete the null ones.