Documentation ¶
Overview ¶
Package iocodec provides multiple input decoders and output encoders.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultDecoders = DecoderGroup{ "xml": DecoderMakerFunc(func(r io.Reader) Decoder { return xml.NewDecoder(r) }), "json": DecoderMakerFunc(func(r io.Reader) Decoder { return json.NewDecoder(r) }), "yaml": DecoderMakerFunc(func(r io.Reader) Decoder { return &yamlDecoder{r} }), }
DefaultDecoders contains the default list of decoders per MIME type.
var DefaultEncoders = EncoderGroup{ "xml": EncoderMakerFunc(func(w io.Writer) Encoder { return &xmlEncoder{w} }), "json": EncoderMakerFunc(func(w io.Writer) Encoder { return &jsonEncoder{w, false} }), "prettyjson": EncoderMakerFunc(func(w io.Writer) Encoder { return &jsonEncoder{w, true} }), "yaml": EncoderMakerFunc(func(w io.Writer) Encoder { return &yamlEncoder{w} }), }
DefaultEncoders contains the default list of encoders per MIME type.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder interface {
Decode(v interface{}) error
}
A Decoder decodes data into v.
type DecoderGroup ¶
type DecoderGroup map[string]DecoderMaker
A DecoderGroup maps MIME types to DecoderMakers.
type DecoderMaker ¶
A DecoderMaker creates and returns a new Decoder.
type DecoderMakerFunc ¶
DecoderMakerFunc is an adapter for creating DecoderMakers from functions.
func (DecoderMakerFunc) NewDecoder ¶
func (f DecoderMakerFunc) NewDecoder(r io.Reader) Decoder
NewDecoder implements the DecoderMaker interface.
type Encoder ¶
type Encoder interface {
Encode(v interface{}) error
}
An Encoder encodes data from v.
type EncoderGroup ¶
type EncoderGroup map[string]EncoderMaker
An EncoderGroup maps MIME types to EncoderMakers.
type EncoderMaker ¶
An EncoderMaker creates and returns a new Encoder.
type EncoderMakerFunc ¶
EncoderMakerFunc is an adapter for creating EncoderMakers from functions.
func (EncoderMakerFunc) NewEncoder ¶
func (f EncoderMakerFunc) NewEncoder(w io.Writer) Encoder
NewEncoder implements the EncoderMaker interface.