Code-Memo

encoding/json

Marshal and unmarshal JSON with struct tags.

Marshal / unmarshal
type User struct {
	Name string `json:"name"`
	Age  int    `json:"age,omitempty"`
}

b, err := json.Marshal(User{Name: "Ada", Age: 36})
var u User
err = json.Unmarshal(b, &u)
Streams
dec := json.NewDecoder(r)
enc := json.NewEncoder(w)

Decoder respects io.Reader streaming; use DisallowUnknownFields() for strict APIs.

json.RawMessage

Delay parsing of nested blobs.

Numbers

By default Decoder unmarshals numbers to float64. Use Decoder.UseNumber() and json.Number for big integers/decimals without float loss when appropriate.

HTML escaping

SetEscapeHTML(false) on Encoder when writing non-HTML contexts.

Performance

easyjson, jsoniter, or codegen exist for hot paths — profile first.