When using:
var dataToSave = ko.toJSON(myViewModel);
.. is it possible to not serialize values that are null?
Serializing my current viewModel creates around 500Kb of JSON most of which is ends up like:
"SomeObject": {
"Property1": 12345,
"Property2": "Sometext",
"Property3": null,
"Property4": null,
"Property5": null,
"Property6": null,
"Property7": null,
"Property8": null,
"Property9": false
}
If I could get the serializer to ignore null values then this could be reduced down to:
"SomeObject": {
"Property1": 12345,
"Property2": "Sometext",
"Property9": false
}
Any ideas how I can instruct the serializer to ignore the null values??
ko.toJSON(myViewModel, (k, v) => v === null ? undefined : v)
– Lavinalavine