I’m using a js file from json.org which creates and parses JSON object representations in JavaScript. However, it seems that the JSON object only puts object state into the string…does anyone know how I can store the prototype functions as well?
When I get this string back and I need to construct an object I can restore the state just fine…but the state is virtually useless without my accessor/mutator methods…and I have multiple types of objects so I don’t know which is which to go back and individually assign prototype functions…
for example, I could do:
var myObj = JSON.parseJSON( jsonString );
myObj.method1 = MyClass.prototype.method1;
myObj.method2 = MyClass.prototype.method2;
…
But this is tedious, and requires that I store class names as part of all my objects just so that I can use conditional logic to restore the prototype methods that should be there anyways…if anyone can spread some light on this issue I would appreciate it.
Thanks.