you can define .toJSON() methods for any enumerable property type that doesn't have a usable toString() for JSON, like Function or Element...
for example:
Code:
//new serializer methods:
Function.prototype.toJSON=function(){return this+'';}
Element.prototype.toJSON=function(){return this.value||this.text||this.textContent||this.innerHTML||"";}
//data to be serialized:
var o={
num: 1,
fun: function me(){return this;},
dom: document.getElementsByTagName("title")[0]
};
//test of json serialization with custom method:
alert(JSON.stringify(o, null, "\t"));