I am working on a project which stores all data in key/value pairs. Both the key and value are strings. Changing this is beyond the current scope. Each data concept is represented by a protobuf message.
So, I must store a protobuf message as a string. Is it enough to store the message as message.toByteString().toString()? Or should I encode the byte[], with Base32 encoding for example?
edit
Using ByteString for persistency does not seem to work:
Message m = ...;
ByteString s = m.toByteString();
ByteString s_ = ByteString.copyFromUtf8(s.toStringUtf8());
Message.PARSER.parseFrom(s_);
While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either than the input has been truncated or that an embedded message misreported its own length.
So do you propose to use Base32 encoding on m.toByteArray()? Please note that changing the data type from string to byte[] currently is out of scope.
Thank you!