msgpack-lite
msgpack-lite copied to clipboard
Support toJSON?
I'm wondering if it's feasible to implement toJSON support on msgpack-lite?
JSON.stringify() supports handling custom toJSON methods, like:
function MyData () {}
MyData.prototype.toJSON = function() {
return { custom: new Custom(), output: 2 };
}
function Custom() {}
Custom.prototype.toJSON = function() { return "recursive"; }
JSON.stringify(new MyData())
// => "{"custom":"recursive","output":2}"
Would be great to have the ability to customize the serialization for msgpack too.
Cheers!
Some of Objects already support toJSON() serializing method.
It sounds a good idea to divert it for us instead of building our own toMsgpack() method.
Thanks.