3 ms·
>how do you embed comments in protocolbuf data? It's binary! In addition to the binary format, every proto message can also be represented in a human readable
by Rebelgecko 4y ago
>how do you embed comments in protocolbuf data? It's binary!
In addition to the binary format, every proto message can also be represented in a human readable form[1]. This is not as efficient and probably not a good idea for data being sent over the wire as-is.. especially if it is only being written and read by computers.
However if you have small amounts of data at rest (like input for a unit test) it can be handy to add some comments explaining anything non-obvious.
On top of that, the proto's schema itself can have comments, and those comments can trickle down into the code generation for a given language so that you can read them when working with your messages. Maybe that's also possible with JSON schemas but idk what their tooling ecosystem is like
[1]: https://developers.google.com/protocol-buffers/docs/text-format-spec https://developers.google.com/protocol-buffers/docs/text-for...