using rapidJSON I am able to store data of any type (supported by rapidJSON) as value against a key. Can I do that in protobuf? If so, how?
The reason I opted for protobuf over rapidJSON is because of its speed (and key comparison in rapidJSON is really a "string" comparison which is costly). Or is there any alternative to that? maybe flatbuffers?
Requirement is storing data of any type against an int type key. Faster serialization/deserialization than regular json.
Looking for answers from C++ perspective.
In protobuf, typically you have a fixed contract that pre-interprets given keys as given types, but: there is also the concept of extensions. With an extension, arbitrary data can be stored against field-numbers; this works for any type that could also have been expressed using the regular API.
The convenience and performance of the extension API depends on the implementation, but it should be perfectly usable from the official C++ API.
The key point about extensions is that only the consumer needs to understand them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With