SEANK.H.LIAO

proto encoding

protobuf encoding x3

protobuf encoding

So many docs, but they never show us what it actually looks like

proto

 1syntax="proto3";
 2
 3message Msg {
 4  string one = 1;
 5  int64 two = 2;
 6  bool three = 3;
 7  float four = 4;
 8  repeated string five = 5;
 9  map<string, int64> six = 6;
10  E seven = 7;
11}
12
13enum E {
14  UNKNOWN = 0;
15  KNOWN = 1;
16}

go

1msg := &Msg{
2        One:   "een",
3        Two:   2,
4        Three: true,
5        Four:  4.4,
6        Five:  []string{"vijf", "fünf"},
7        Six:   map[string]int64{"zes": 6},
8        Seven: E_KNOWN,
9}

prototext

 1PROTO TEXT MARSHAL
 2one:"een"  two:2  three:true  four:4.4  five:"vijf"  five:"fünf"  six:{key:"zes"  value:6}  seven:KNOWN
 3
 4PROTO TEXT FORMAT
 5one:  "een"
 6two:  2
 7three:  true
 8four:  4.4
 9five:  "vijf"
10five:  "fünf"
11six:  {
12  key:  "zes"
13  value:  6
14}
15seven:  KNOWN

protojson

 1PROTO JSON MARSHAL
 2{"one":"een", "two":"2", "three":true, "four":4.4, "five":["vijf", "fünf"], "six":{"zes":"6"}, "seven":"KNOWN"}
 3
 4PROTO JSON FORMAT
 5{
 6  "one":  "een",
 7  "two":  "2",
 8  "three":  true,
 9  "four":  4.4,
10  "five":  [
11    "vijf",
12    "fünf"
13  ],
14  "six":  {
15    "zes":  "6"
16  },
17  "seven":  "KNOWN"
18}

protowire

1PROTO MARSHAL
2
3een%�@*vijf*fünf2
4zes8
5
6PROTO MARSHAL HEX
70a 03 65 65 6e 10 02 18 01 25 cd cc 8c 40 2a 04 76 69 6a 66 2a 05 66 c3 bc 6e 66 32 07 0a 03 7a 65 73 10 06 38 01