Comments on: HydrateJS: Smarter Javascript Serialization https://blog.maxaller.name/2011/01/hydratejs-smarter-javascript-serialization/ ruby, ubuntu, etc Thu, 17 Mar 2016 20:35:40 +0000 hourly 1 http://wordpress.org/?v=3.5.1 By: Max https://blog.maxaller.name/2011/01/hydratejs-smarter-javascript-serialization/comment-page-1/#comment-690 Max Mon, 07 Mar 2011 04:42:52 +0000 https://blog.maxaller.name/?p=455#comment-690 You have to instantiate Hydrate — that’s how you configure it (specifying an error handler, migrations, and the resolver). The empty constructor is fine: new Hydrate(). Check out the specs for some examples: https://github.com/nanodeath/HydrateJS/blob/master/spec/HydrateSpec.js

FYI, the resolver is how strings representing the classes are mapped back into actual classes after deserialization.

]]>
By: treaint https://blog.maxaller.name/2011/01/hydratejs-smarter-javascript-serialization/comment-page-1/#comment-689 treaint Wed, 02 Mar 2011 18:54:17 +0000 https://blog.maxaller.name/?p=455#comment-689 I am trying to use HydrateJS to serialize an object with circular references and functions. I modified the source as follows for it to serialize functions:
1)
case “function”:
//throw new Error(“can’t serialize functions”);
//break;
return uneval(eval(input));

2)
case “function”:
//return this.errorHandler(new Hydrate.NonPrototypeFunctionError(input, name));
return uneval(eval(input));

It currently serializes my object just fine.
However when I try to deserialize it I get the following error:
No Hydrate resolver found — you should specify one in the Hydrate constructor!

I’m not sure if that’s caused by my changes or if I’m doing something wrong:
var serialized = Hydrate.prototype.stringify(object);
var deserialized = Hydrate.prototype.parse(serialized);

]]>