I'm trying to serialize a JavaScript object to json, to be deserialized later back into its original form.
The hard part is that it's not just primitives I need to serialize. For example:
function Foo() {
this.bar = "Hello World";
}
Foo.prototype.baz = function() {
alert(this.bar);
}
var qux = new Foo();
How would I serialize qux? If I simply JSON.stringify then JSON.parse it, I wouldn't be able to call qux.baz().
Are there any standards or tools or techniques out there to do this? Any tips to point me in the right direction?
Thanks.
JSON.stringify( yourObject )yet?