Reputation: 1037
I'm analysing some protobuf data using https://protogen.marcgravell.com/decode and i cannot make sense of this:
I'm reading through the protobuf encoding guide and i can see the data doesn't have to be a string, but rather something length-delimited string, bytes, embedded messages, packed repeated fields
What i don't understand is why it has a perfectly good string apples1
in field 105, but then 3x random empty payloads for the same field 105? Is this just some oddness with the 3rd parties use of protbufs that i'm looking at, or is it something else i'm missing?
Thanks in advance.
Upvotes: 1
Views: 115
Reputation: 1063864
There's nothing especially unusual about empty strings; however, it is also entirely possible that they are sub-messages - just objects without any interesting properties. A nil (not assigned / null / etc) sub-message won't be present at all, but a non-nil sub-message without any interesting content will be: a zero-byte binary string (in protobuf terms).
Likewise: a bytes
field that is explicitly assigned a zero-length buffer: will be a zero-byte binary string. And: a "packed" array with zero elements: will be a zero-byte binary string.
So: nothing unusual here - that's perfectly normal and expected protobuf for a range of scenarios.
Since the field number doesn't change, it sounds like something like:
repeated string whatever = 105;
i.e.
obj.Whatever = [ "apples1", "", "", "" ];
Odd, but not invalid.
Upvotes: 3