Documentation ¶
Overview ¶
Package json 提供了围绕标准库或第三方库的 JSON 操作,实现了对 JSON 的封装并忽略它们。
Index ¶
- func Marshal(v interface{}) (marshaledBytes []byte, err error)
- func MarshalIndent(v interface{}, prefix, indent string) (marshaledBytes []byte, err error)
- func NewDecoder(reader io.Reader) *json.Decoder
- func NewEncoder(writer io.Writer) *json.Encoder
- func Unmarshal(data []byte, v interface{}) (err error)
- func UnmarshalUseNumber(data []byte, v interface{}) (err error)
- func Valid(data []byte) bool
- type RawMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
Marshal 适应 json/encoding 库的 Marshal API.
Marshal 返回参数 v 的 JSON 编码结果,此方法适应于 json/encoding 库中的 Marshal API, 更多信息请参考 https://godoc.org/encoding/json#Marshal 。
func MarshalIndent ¶
MarshalIndent 与 json.MarshalIndent 功能相同。
func NewDecoder ¶
NewDecoder 适应于 json/stream 的 NewDecoder API。
NewDecoder 函数返回一个从 r 读取数据的新解码器。
返回的不是一个 json/encoding 包中的 Decoder,而是一个自定义的 Decoder。 有关更多信息,请参考 https://godoc.org/encoding/json#NewDecoder 。
func Unmarshal ¶
Unmarshal 适应 json/encoding 的 Unmarshal API
Unmarshal 解析 JSON 编码的数据,并将结果存储在 v 指向的值中。 有关更多信息,请参考 https://godoc.org/encoding/json#Unmarshal 。
func UnmarshalUseNumber ¶
UnmarshalUseNumber 使用数字选项将json数据字节解码到目标接口。
Types ¶
type RawMessage ¶
type RawMessage = json.RawMessage
RawMessage 是一个原始编码的 JSON 值。 它实现了 Marshaler 和 Unmarshaler 接口,可用于延迟 JSON 解码或预计算 JSON 编码。