JSON.stringify omits values that are not valid JSON, including undefined and Function.
If you really really want to, you could use the replacer parameter (not sure how cross-browser this will be though) and work around this. This function will basically inspect to see if the value is a function, and it will return the function name. In your example, it will return "String", since String is a global constructor function.
JSON.stringify(your_object, function (key, value) {
if (typeof value === "function") {
return value.name; // or value.toString() for the function body/declaration
}
return value;
});
Although, to be clear, you're better off using a string as your type, ("String" instead of String) no hoops to jump through then.
Functiontypes when serializing, since they are not valid in JSON.Stringfor?