Open DianaSuvorova opened 4 years ago
Bytes are just small integer numbers, why would you assume that an array of them is a String? In UTF-8 even, why not ASCII? I could understand if this were an array of characters. Am I missing something?
@sheepdreamofandroids you are correct, bytes are just small numbers. In case when you communicate over Json, there is no such type as byte
, so byte array will be transferred as an array of integers
. So normally if you need to transfer byteArray via Json you'd convert it to string, most commonly using base64. In this particular example, I thought using utf-8 is ok, because these bytes are from proto's byteString which I thought already is using utf-8. internally, but I might be totally wrong, and it may need other decoder.
I see, you simply want a more compact encoding of the bytes. In that case I think that base64 is much safer than a straightforward conversion to text because you avoid all kinds of transformations based on encodings. On the other hand, if that kind of efficiency is important to you, why not use protobuf or another binary encoding on the client side as well? Nobody forces you to use JSON.
Currently bytes are returned as an array of bytes, which gets transferred as an array of numbers in Json.
This pr changes so the input and the output for Bytes is expected to be utf-8 encoded string