[Project_owners] Javascript (de)serialization question

Nickolay Ponomarev asqueella at gmail.com
Mon Mar 13 04:30:14 EST 2006

Eric H. Jung wrote:
> Warning: This was posted at http://forums.mozillazine.org/viewtopic.php?t=388554, but I'm hoping
> to get a more timely reply from this group. IMHO, the quality of forums.mozillazine.org has
> suffered in recent months, I think due to a heavy stream of Javascript newbies. Nickolay, I
> apologize if this dual-post offends you. I am only trying to make progress - to move forward in a
> reasonable time.

> I'm trying to use toSource() and eval() for serialization and deserialization of JS objects of my
> own class. I find that serialization works, but the object's type ("class") is lost on
> deserialization. For example, given the following class:

IMO you should keep serializable data in a separate object (not a class, a 
simple object), but if you really want to, you can set the "class" of an object, 
after it is deserialized, by setting __proto__ manually (to Proxy.prototype).

You didn't explain the problem you're trying to solve though, - *why* do you 
want to serialize your classes?


More information about the Project_owners mailing list