For instance, in which cases am I allowed to specify enum values as strings rather than numbers?
syntax = "proto3";
message DeviceReadings {
enum Foo {
ONE = 0;
TWO = 1;
}
Foo foo = 1;
}
When I use a string in encode it seems to fall back to the default value:
> DeviceReadings.decode(DeviceReadings.encode({foo: 'TWO'}).finish())
DeviceReadings { foo: 0 }
But if I go through fromObject first then it works:
> DeviceReadings.decode(DeviceReadings.encode(DeviceReadings.fromObject({foo: 'TWO'})).finish())
DeviceReadings { foo: 1 }
But with create it works the same as encode alone:
> DeviceReadings.decode(DeviceReadings.encode(DeviceReadings.create({foo: 'TWO'})).finish())
DeviceReadings { foo: 0 }
Is all that documented somewhere?
For instance, in which cases am I allowed to specify enum values as strings rather than numbers?
When I use a string in
encodeit seems to fall back to the default value:But if I go through
fromObjectfirst then it works:But with
createit works the same asencodealone:Is all that documented somewhere?