// A Decoder reads and decodes JSON values from an input stream. type Decoder struct { r io.Reader buf []byte d decodeState scanp int// start of unread data in buf scan scanner err error
tokenState int tokenStack []int }
// An Encoder writes JSON values to an output stream. type Encoder struct { w io.Writer err error escapeHTML bool
// Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by v. // acts like UnMarshal func(dec *Decoder)Decode(v interface{})error { ... err = dec.d.unmarshal(v) ... }
// Encode writes the JSON encoding of v to the stream, followed by a newline character. // acts like Marshal func(enc *Encoder)Encode(v interface{})error { ... e := newEncodeState() err := e.marshal(v, encOpts{escapeHTML: enc.escapeHTML}) if err != nil { return err } ... }