json

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Marshal 封装了 gojson/json 包的 Marshal 函数。
	Marshal = json.Marshal
	// Unmarshal 封装了 gojson/json 包的 Unmarshal 函数。
	Unmarshal = json.Unmarshal
	// MarshalIndent 封装了 gojson/json 包的 MarshalIndent 函数。
	MarshalIndent = json.MarshalIndent
	// NewDecoder 是一个函数,返回一个新的自定义 Decoder 实例。
	NewDecoder = func(r io.Reader) *Decoder {
		return &Decoder{decoder: json.NewDecoder(r)}
	}
	// NewEncoder 是一个函数,返回一个新的自定义 Encoder 实例。
	NewEncoder = func(w io.Writer) *Encoder {
		return &Encoder{encoder: json.NewEncoder(w)}
	}
)

Functions

This section is empty.

Types

type Decoder added in v1.0.3

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

Decoder 是一个用于解码 JSON 的自定义结构体。

func (*Decoder) Decode added in v1.0.3

func (d *Decoder) Decode(v interface{}) error

Decode 读取下一个 JSON 编码值并将其存储在由 v 指向的值中。

type Encoder added in v1.0.3

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

Encoder 是一个用于编码 JSON 的自定义结构体。

func (*Encoder) Encode added in v1.0.3

func (e *Encoder) Encode(v interface{}) error

Encode 将 v 的 JSON 编码写入流中。

Jump to

Keyboard shortcuts

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