-
Notifications
You must be signed in to change notification settings - Fork 126
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
Newbie Question: How to unpack a base64 encoded string which encapsulates data #52
Comments
Decoding from base64: msgpack.decode(Buffer.from('pWhlbGxv', 'base64')) // => hello Encoding to base64: msgpack.encode("hello").toString('base64') // => pWhlbGxv |
The base64 encoded string has encapsulated data. I actually have a nodejs script that decodes this, and Im trying to convert it to client side js that will work on most browsers. Here's the nodejs code snippet on how it is upacked:
How can I use msgpack-lite to decode like this? |
var msgpack = require("msgpack-lite");
var strBuffer = new Buffer(base64EncodedString, 'base64');
var unpacked = msgpack.decode(strBuffer);
console.warn(unpacked); |
Hi, In my Java code i have tested the example code from the official msgpack java repository: I can decode the first integer in the browser but all other packages not. Cheers! |
Use event mode of the module: var msgpack = require("msgpack-lite");
var decoder = msgpack.Decoder();
decoder.on("data", function(data) {
// you'll receive 1, "leo", 2, "xxx-xxxx" and "yyy-yyyy" in order
});
decoder.on("end", function() {
//
});
decoder.decode(buf); |
soo cool:D thank you very much! |
Hi,
We have a service that packs some data (int, int, boolean) and encodes it (base 64 encoding). It spits out the base64 encoded string. Now I am creating a client side javascript that decodes this string. How do I use it using msgpack-lite? I've read that a multi-level msgpack requires a different handling. Please advise.
Cheers!
The text was updated successfully, but these errors were encountered: