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

MsgpackEmitter encodes byte[] as a base64 string #17

Closed
chris-zen opened this issue Feb 21, 2016 · 2 comments
Closed

MsgpackEmitter encodes byte[] as a base64 string #17

chris-zen opened this issue Feb 21, 2016 · 2 comments

Comments

@chris-zen
Copy link

When writing an array of bytes Transit uses the BinaryWriteHandler which gives the b tag. Then for that tag, the AbstractEmitter calls the function emitBinary. Its implementation in MsgpackEmitter encodes the array of bytes as Base64 and emits an string as follows:

byte[] encodedBytes = Base64.encodeBase64((byte[])b);
emitString(Constants.ESC_STR, "b", new String(encodedBytes), asMapKey, cache);

Reading the specs of MessagePack I see that they have native support for encoding binary data without having to use strings encoded as Base64. I can understand this strategy for the JSON emitters but not for the Msgpack one.

@chris-zen
Copy link
Author

I just realised that the Transit specs mandate to encode binary data as a base64 string. I don't really understand this decision, and makes me realise that using the MSGPACK format is not that much better than using the JSON one.

@puredanger
Copy link
Contributor

FYI, there is more discussion of this here: cognitect/transit-format#2

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