On Thu, Sep 22, 2011 at 03:32, Suraj <surajn.v...@gmail.com> wrote:
> Hi,
> Say I have two messages a and b of types A and B respectively.
> Can I serialize them to the same string?
> Something like..
> a.SerializeToString(&str);
> b.SerializeTostring(&str_new);
> str.append(str_new);
> Then while parsing, I will do,
> a.ParseFromString(str)
> and b.ParseFromString(str).
> I have tried this and it is working. But want to confirm whether it's
> a correct thing to do or not?

What you get is that message a and b both have the same content, more
precisely, the merged content of both the original messages ( see
for merging ).

Not sure if this is what you want.

If you want to serialize multiple different messages in one string,
you need to put them in some kind of container format, e.g.
<length1><message1><length2><message2> .... this has been discussed on
list several times. You also find documentation in 'Techniques'


You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to