json

package
v1.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MarshalFunc       = json.Marshal
	MarshalIndentFunc = json.MarshalIndent
	UnmarshalFunc     = json.Unmarshal
	NewEncoderFunc    = func(w io.Writer) Encoder { return json.NewEncoder(w) }
	NewDecoderFunc    = func(r io.Reader) Decoder { return json.NewDecoder(r) }
)

Functions

func Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal returns the JSON encoding of v.

func MarshalIndent

func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error)

MarshalIndent is like Marshal but applies Indent to format the output.

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v.

Types

type Decoder

type Decoder interface {
	Decode(v interface{}) error
}

Decoder decodes a byte sequence.

func NewDecoder

func NewDecoder(r io.Reader) Decoder

NewDecoder returns a new decoder that reads from r.

type Encoder

type Encoder interface {
	Encode(v interface{}) error
}

Encoder encodes into byte sequence.

func NewEncoder

func NewEncoder(w io.Writer) Encoder

NewEncoder returns a new encoder that writes to w.

type WrapDecoder

type WrapDecoder struct {
	D Decoder
}

func (*WrapDecoder) Decode

func (w *WrapDecoder) Decode(v interface{}) error

Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by v.

type WrapEncoder

type WrapEncoder struct {
	E Encoder
}

func (*WrapEncoder) Encode

func (w *WrapEncoder) Encode(v interface{}) error

Encode encodes into byte sequence.

type WrapError

type WrapError struct {
	// contains filtered or unexported fields
}

func (*WrapError) Error

func (w *WrapError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL