I have a very simple enum, and when i decode a message the enum is the value rather than the key.
Is this on purpose? My initial thinking was that the enum gets translated to value, communicated, then translated back to the key when a message is decoded.
enum Carrier {
T_MOBILE = 0;
ATT = 1;
}
message Test {
Carrier carrier = 1;
}
var buf = messages.Test.encode({
carrier: messages.Carrier.ATT
});
var obj = messages.Test.decode(buf)
console.log(obj)
>> { carrier: 1 }
Expected (something like this):
var obj = messages.Test.decode(buf)
console.log(obj)
>> { carrier: 'ATT' }
I can get the key with additional step using lodash, but like i mentioned above, that feels contrary to what i was expecting.
I have a very simple enum, and when i decode a message the enum is the value rather than the key.
Is this on purpose? My initial thinking was that the enum gets translated to value, communicated, then translated back to the key when a message is decoded.
Expected (something like this):
I can get the key with additional step using lodash, but like i mentioned above, that feels contrary to what i was expecting.