knockout/knockout — pull request #1079 by rniemeyer (2013-10-10 01:23:07+00:00)
Title: Backwards compatibility of 3.0.0beta with ko.toJSON

Hi,

I'm currently in the process of upgrading to 3.0.0beta and have found a breaking change in the way ko.toJSON now works.

As it now strips out functions (from within ko.toJS) any custom formatters that would rely on those functions will begin to fail.

In my specific example this happens if a value in an observable is a moment (http://momentjs.com/) and to toJSON function looks like:

moment.fn.toJSON = function () {
return this.format('YYYY-MM-DDT00:00:00ZZ');
};

By stripping out the functions attached to the object format is undefined. From memory I believe you made this change to fix another bug. I do not know which way makes most sense with regards to this, but at a minimum this probably needs calling out in the release notes.

Thanks,
Adam