FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
310 stars 133 forks source link

How to write Binary without base64 encoding #321

Closed karlduderstadt closed 2 years ago

karlduderstadt commented 2 years ago

First of all, thanks for creating this awesome data format!!

This is more of a question, than an issue. Is there a way to directly write a byte[] to a field with no base64 encoding at all?

Currently, I am using the SmileGenerator method writeBinaryField. I would like to one-to-one write and later read back a byte[] array I am providing for a given field. When using smile, is this how the writeBinaryField works or does it still do some kind of base64 encoding and then write that as binary?

Thanks!!

cowtowncoder commented 2 years ago

Smile backend will use its own encoding (either 7-bit-per-byte null-safe encoding, or "raw" inclusion -- for latter there is SmileGenerator.Feature to enable). It will not use Base64 encoding in any case; user may of course pre-encode binary, but SmileGenerator should not do that ever.

I hope this helps.

karlduderstadt commented 2 years ago

Yes, this helps a lot and answer my question! I will close the issue.

I wasn't sure because that the javadoc for that method seemed to suggest it would use base64 encoding, but I guess that is for the default JsonGenerator that is writing a text file.

Thanks very much for your super fast reply and helpful feedback!!