Playground
One schema, three samples. The bytes, the JSON and the text below were all written by this library; the page only switches between them.
syntax = "proto3"; package demo; enum Color { RED = 0; BLUE = 1; } message Envelope { int32 id = 1; string name = 2; map<string, int32> counts = 3; Color color = 4; }
starting the engine
A field is one tag byte and its payload. The low three bits of the tag carry the wire type, so the decoder knows whether to read a varint, eight bytes, or a length followed by that many bytes.
1 (key) and 2 (value); protobuf has no separate map encoding on the wire.