1package json 2 3import ( 4 "encoding/json" 5) 6 7// Codec implements the encoding.Encoder and encoding.Decoder interfaces for JSON encoding. 8type Codec struct{} 9 10func (Codec) Encode(v map[string]any) ([]byte, error) { 11 // TODO: expose prefix and indent in the Codec as setting? 12 return json.MarshalIndent(v, "", " ") 13} 14 15func (Codec) Decode(b []byte, v map[string]any) error { 16 return json.Unmarshal(b, &v) 17} 18 19