protobuf

361 阅读1分钟
  • 关键字
proto3 json example
message object {"":,"":,}
enum string "1"
map object {"":,"":,}
repeated V array [v,...]
bool true,false
string string
bytes base64 string "YWJjMT"
int32,fixd32,uint32 number 1,-10,0
int64,fixed64,uint64 string "1","-10"
Any object
Timestamp string
Duration string "1s","1.02s"
Struct object
Wrapper types various types
ListValue array
Value value 任意JSON
NullValue null
  • filed 字段

2^4-1 = 1-15 是保留给常用字段 16-5XXX(不包括19000-19999) 2bit

小知识

  • varint

flag|7bit

flag=0 无后续 1 有后续

都是varint 包括tag V

  • TLV

tag(field+wire_type)+length+Value

0125 0 varint 1 fix64 5 fix32 2 ??