-
Notifications
You must be signed in to change notification settings - Fork 131
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
Compatibility mode #22
Comments
Hi, The library supports the current version of msgpack spec. They say, by the way, msgpack would add a new official ext format for nano precision date time. |
We run systems that were written longer than 3 years ago. For these systems there's no drop in replacement for the newer spec implementation so updating msgpack would mean getting involved in much larger scope updates or manually port the newer spec. If you're not keen on implementing compatibility mode yourself but would consider accepting patches, could you outline an implementation for which you would consider accepting a pull request. |
I see. Do you have any reference implementation of compatibility_mode on the other npm modules to have compatibility / interoperability? Ruby implementation have compatibility_mode option for instance. |
Hi, We did some research and found no other node/JavaScript library implementing compatibility mode. As you pointed out Here's the PR for the ruby compatibility implementation https://github.com/msgpack/msgpack-ruby/pull/68/files Also there's this python lib that implements compatibility mode https://github.com/vsergeev/u-msgpack-python#compatibility-mode |
The compatibility mode added at version 0.1.19! https://www.npmjs.com/package/msgpack-lite#compatibility-mode // default mode handles both str and bin formats individually
msgpack.encode("Aa"); // => <Buffer a2 41 61> (str format)
msgpack.encode(new Buffer([0x41, 0x61])); // => <Buffer c4 02 41 61> (bin format)
msgpack.decode(new Buffer([0xa2, 0x41, 0x61])); // => 'Aa' (String)
msgpack.decode(new Buffer([0xc4, 0x02, 0x41, 0x61])); // => <Buffer 41 61> (Buffer)
// compatibility mode handles only raw format both for String and Buffer
var options = {codec: msgpack.createCodec({useraw: true})};
msgpack.encode("Aa", options); // => <Buffer a2 41 61> (raw format)
msgpack.encode(new Buffer([0x41, 0x61]), options); // => <Buffer a2 41 61> (raw format)
msgpack.decode(new Buffer([0xa2, 0x41, 0x61]), options); // => <Buffer 41 61> (Buffer)
msgpack.decode(new Buffer([0xa2, 0x41, 0x61]), options).toString(); // => 'Aa' (String) |
thanks a lot! |
Right. The most difference is old var options = {codec: msgpack.createCodec({useraw: true})}; The |
If this library is supporting a newer version of the spec it should document if it supports compatibility mode with the old spec and how to use that:
excerpt from https://github.com/msgpack/msgpack/blob/master/spec.md
"In a major release, serializers distinguish Binary type and String type using bin format family and str format family
At the same time, serializers should offer "compatibility mode" which doesn't use bin format family and str 8 format"
The text was updated successfully, but these errors were encountered: