Is it possible to use google.protobuffer to serialize data without prefixing the length of each data field?

Viewed 524

By default, unless ive done something wrong, protobuf prefixes all data fields with the length of the data that follows. for example, if i do:

class Program
{
    static void Main(string[] args)
    {
        MessagePayload msg = new MessagePayload()
        {
            Message = "hello"
        };

        var bytes = new byte[8];

        var output = new CodedOutputStream(bytes);

        output.WriteMessage(msg);

        Console.WriteLine(CryptoBytes.ToHexStringLower(bytes));

        Console.ReadLine();
    }
}

it prints out:

07120568656c6c6f

but what i want is:

0568656c6c6f

is there a way to have protobuf do this somehow, without manually removing the length fields?

2 Answers
Related