Convert a bson Document to byte array java

873 views Asked by At

Have a use case where I need to compress and store a org.bson.Document into cache. I am using zstd compression which expects a byte array. Not able to find a way to convert Document into byte array.

1

There are 1 answers

0
Hellothisisme On

Only way I know of is to go via a JSON file, and then to a ByteArray.

You would then have to go via a JSON back to BsonDocument for when you want to use it again.