Skip to content

Commit 6048815

Browse files
Fix proto encoding docs
The repeated field docs seem to have gotten mixed up when updating them to be packed-first; I changed it so the shown hex and protoscope output matches the description. Also changed the field numbers to follow the existing pattern. PiperOrigin-RevId: 926051528
1 parent d6509af commit 6048815

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

content/programming-guides/encoding.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,17 @@ the field. Thus, if we have:
318318
```proto
319319
message Test4 {
320320
string d = 4;
321-
repeated int32 e = 6;
321+
repeated int32 e = 5;
322322
}
323323
```
324324

325325
and we construct a `Test4` message with `d` set to `"hello"`, and `e` set to
326-
`1`, `2`, and `3`, this *could* be encoded as `` `3206038e029ea705` ``, or
327-
written out as Protoscope,
326+
`1`, `2`, and `3`, this *could* be encoded as `` `220568656c6c6f2a03010203` ``,
327+
or written out as Protoscope,
328328

329329
```proto
330330
4: {"hello"}
331-
6: {3 270 86942}
331+
5: {1 2 3}
332332
```
333333

334334
However, if the repeated field is set to expanded (overriding the default packed
@@ -339,10 +339,10 @@ records for the same field with respect to each other is preserved. Thus, this
339339
could look like the following:
340340

341341
```proto
342-
6: 1
343-
6: 2
342+
5: 1
343+
5: 2
344344
4: {"hello"}
345-
6: 3
345+
5: 3
346346
```
347347

348348
Only repeated fields of primitive numeric types can be declared "packed". These
@@ -355,8 +355,9 @@ must contain a whole number of elements. The following is a valid encoding of
355355
the same message above that parsers must accept:
356356

357357
```proto
358-
6: {3 270}
359-
6: {86942}
358+
5: {1 2}
359+
4: {"hello"}
360+
5: {3}
360361
```
361362

362363
Protocol buffer parsers must be able to parse repeated fields that were compiled

0 commit comments

Comments
 (0)