Documentation ¶
Overview ¶
Package implementing the JSON -- http://json.org/ -- spec.
The `json.Marshal` and `json.Unmarshal` functions are the quickest way to convert your Go objects to and from serial JSON.
The `json.NewMarshaller` and `json.NewUmarshaller` functions give a little more control. If performance is important, prefer these; recycling the marshaller instances will significantly cut down on memory allocations and improve performance.
The `*Atlased` variants of constructors allow you set up marshalling with an `refmt/obj/atlas.Atlas`, unlocking all of refmt's advanced features and custom object mapping powertools.
The `json.Encoder` and `json.Decoder` types implement the low-level functionality of converting serial JSON byte streams into refmt Token streams. Users don't usually need to use these directly.
Index ¶
- func Marshal(v interface{}) ([]byte, error)
- func MarshalAtlased(cfg EncodeOptions, v interface{}, atl atlas.Atlas) ([]byte, error)
- func Unmarshal(data []byte, v interface{}) error
- func UnmarshalAtlased(data []byte, v interface{}, atl atlas.Atlas) error
- type DecodeOptions
- type Decoder
- type EncodeOptions
- type Encoder
- type Marshaller
- type Unmarshaller
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalAtlased ¶
func MarshalAtlased(cfg EncodeOptions, v interface{}, atl atlas.Atlas) ([]byte, error)
Types ¶
type DecodeOptions ¶
type DecodeOptions struct { }
func (DecodeOptions) IsDecodeOptions ¶
func (DecodeOptions) IsDecodeOptions()
marker method -- you may use this type to instruct `refmt.Marshal` what kind of encoder to use.
type EncodeOptions ¶
type EncodeOptions struct { // If set, this will be prefixed to every "line" to pretty-print. // (Typically you want to just set this to `[]byte{'\n'}`!) Line []byte // If set, this will be prefixed $N$ times before each line's content to pretty-print. // (Likely values are a tab, or a few spaces.) Indent []byte }
func (EncodeOptions) IsEncodeOptions ¶
func (EncodeOptions) IsEncodeOptions()
marker method -- you may use this type to instruct `refmt.Marshal` what kind of encoder to use.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
A json.Encoder is a TokenSink implementation that emits json bytes.
func NewEncoder ¶
func NewEncoder(wr io.Writer, cfg EncodeOptions) *Encoder
type Marshaller ¶
type Marshaller struct {
// contains filtered or unexported fields
}
func NewMarshaller ¶
func NewMarshaller(wr io.Writer) *Marshaller
func NewMarshallerAtlased ¶
func NewMarshallerAtlased(wr io.Writer, cfg EncodeOptions, atl atlas.Atlas) *Marshaller
func (*Marshaller) Marshal ¶
func (x *Marshaller) Marshal(v interface{}) error
type Unmarshaller ¶
type Unmarshaller struct {
// contains filtered or unexported fields
}
func NewUnmarshaller ¶
func NewUnmarshaller(r io.Reader) *Unmarshaller
func NewUnmarshallerAtlased ¶
func NewUnmarshallerAtlased(r io.Reader, atl atlas.Atlas) *Unmarshaller
func (*Unmarshaller) Unmarshal ¶
func (x *Unmarshaller) Unmarshal(v interface{}) error