protobuf-java-format icon indicating copy to clipboard operation
protobuf-java-format copied to clipboard

Serialize enum with number by default

Open mchataigner opened this issue 8 years ago • 3 comments

In order to reduce the size of json payload, it should be better to send only the enum number instead of the value name.

mchataigner avatar Feb 23 '17 10:02 mchataigner

I like the idea. Unfortunately it doesn't look like there has been much activity from the committers on this project lately which is a shame because it is an extremely useful library!

melloware avatar Feb 23 '17 11:02 melloware

Is it possible to alter/choose the behavior? I appreciate the feature, but would much prefer making what is desired possible rather than changing the default.

Also, can you add a test for this (that both formats are read properly)?

scr avatar Feb 23 '17 16:02 scr

Actually, it's a matter of compatibility. Enums have both name and order - You can easily break the compatibility by rearranging the order of the enums in your message, while if using name, it is somewhat easier to locate API breakage.

I would go with @scr offer to add a behavior switch and leave the current (by name) behavior as the default one.

bivas avatar Feb 25 '17 11:02 bivas