3 ms·
That kind of encoding is only the right call if you want for a message to be a foo, a bar, OR a foo+bar. If you've got an opcode, name it semantically with a n
by KirinDave 9y ago
That kind of encoding is only the right call if you want for a message to be a foo, a bar, OR a foo+bar.
If you've got an opcode, name it semantically with a name field. If you've got a type to serialize, do it semantically and don't just do like what the library I ported does and put the Golang type annotation in a string.
And don't let objects inhabit a fusion like this. It leads to surprising behavior with malformed messages.
- tree_of_item 9y agoYour schema can simply say it is illegal for an object to have both of those tags once. I'm not sure how you'd do any better with a unityped system like JSON. Unless you're advocating using something other than JSON? What do you mean by "do it semantically"? What other alternative is there besides a field for a type tag?