mochi / mochikit

MochiKit makes JavaScript suck less

Home Page:http://mochi.github.io/mochikit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Base: serializeJSON should support toJSON()

blq opened this issue · comments

I think serializeJSON should recognize the toJSON() method by default now that it has been standardized, see JSON.stringify at http://www.json.org/json2.js.

MochiKit.Base.registerJSON("has_toJSON",
    function(obj)
    {
        return typeof(obj.toJSON) == 'function';
    },
    function(obj)
    {
        return obj.toJSON();
    }
);

Added MochiKit.Base.serializeJSON() support for toJSON() methods. Thanks to Fredrik Blomqvist for suggesting this. Closed by b21ea1c.