So, JSON.stringify provides a great way to turn a JS object like:
var baz = {\"foo\":1, \"bar\":someFunction};
in to a JSON string like:
Crockford's json2.js says:
A toJSON method does not serialize: it returns the value represented by the name/value pair that should be serialized, or undefined if nothing should be serialized.
So you are simply expected to return the value that you want serialized. In your case, baz.toJSON should simply return the portion of the baz object that you want serialized:
someObject.baz.toJSON = function() {
return { foo: this.foo };
};