We noticed funny behaviour when trying to deserialize a byte array that was generated from a proto. I understand that default values don't get serialized, and hence deserializing them is not possible. However, I believe that setting up a default value when converting a bytearray to a map would be immensely helpful, instead of having no keys at all and that resulting in a nil.
Let me illustrate this with an example: Assuming you have a Person proto. Considering we are using proto3, I will not be using required and optional.
package your.namespace.person;
option java_outer_classname = "Example";
message Person {
int32 id = 1;
string name = 2;
string email = 3;
repeated string likes = 4;
}
Now given I have populated a protobuf map of type Person using
{ :id 123 :name "test subject"}
and serialized it to bytes; Once I try to deserialize it, I get a hashmap of
{:id 123 :name "test subject"}
I would instead expect default values to be populated on the resultant map. So; on deserializing, I would expect
{ :id = 123; :name = "test subject" :email = <empty string> :likes = <empty list> }
Is there something I am missing or is this desired behaviour? If it is something that is by design, would you be happy to accept a patch that allows us to populate default values for the fields not sent on the wire?
We noticed funny behaviour when trying to deserialize a byte array that was generated from a proto. I understand that default values don't get serialized, and hence deserializing them is not possible. However, I believe that setting up a default value when converting a bytearray to a map would be immensely helpful, instead of having no keys at all and that resulting in a nil.
Let me illustrate this with an example: Assuming you have a Person proto. Considering we are using proto3, I will not be using
required
andoptional
.Now given I have populated a protobuf map of type Person using
{ :id 123 :name "test subject"}
and serialized it to bytes; Once I try to deserialize it, I get a hashmap of
{:id 123 :name "test subject"}
I would instead expect default values to be populated on the resultant map. So; on deserializing, I would expect
{ :id = 123; :name = "test subject" :email = <empty string> :likes = <empty list> }
Is there something I am missing or is this desired behaviour? If it is something that is by design, would you be happy to accept a patch that allows us to populate default values for the fields not sent on the wire?