Last Updated: May 22, 2026
Some JSON payloads can't be fully described by a single struct. An event stream carries different event shapes under the same envelope. A gateway forwards JSON from a third party without knowing or caring what's inside. json.RawMessage is the tool for those cases: it's a []byte that the encoding/json package treats as already-encoded JSON, so you can defer decoding or pass bytes through untouched.