There's not really an official recommended format for doing this. Probably the easiest thing is to store the raw serialized message, if you can fit everything into one message in a reasonable way without it being too big. The other common approach is just to store a simple series of messages, with each message prefixed by its size as a varint. This is sometimes called the "delimited" format and for some languages we include support for it. For example here is the code implementing it in C++: https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/util/delimited_message_util.h
On Mon, Mar 9, 2020 at 3:30 PM Matthew Eck <[email protected]> wrote: > Is there a recommended, documented format for reading and writing protobuf > mesages to/from a file? > Preferably without converting to JSON. I seek something equivalent to > Google's internal RecordIO format > <https://groups.google.com/d/msg/protobuf/7idXKu-dpwo/xFYnPpUgSJIJ>, > which AFAICT is not published; something like Avro object container file > <https://avro.apache.org/docs/current/spec.html#Object+Container+Files>, > except for protobuf. > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/protobuf/2ba87854-c284-4b42-adef-67f8e4c41081%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/2ba87854-c284-4b42-adef-67f8e4c41081%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/CADqAXr6Zx1GmOKcA7gSD7pUORY8Wgh%3D7cF9_EXA5iW_R6jmZGg%40mail.gmail.com.
