Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support toJSON? #79

Open
endel opened this issue Oct 29, 2017 · 1 comment
Open

Support toJSON? #79

endel opened this issue Oct 29, 2017 · 1 comment

Comments

@endel
Copy link

endel commented Oct 29, 2017

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!

@kawanet
Copy link
Owner

kawanet commented Nov 27, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants