json

package
v0.0.0-...-2910145 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package json 提供了围绕标准库或第三方库的 JSON 操作,实现了对 JSON 的封装并忽略它们。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

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

Marshal 适应 json/encoding 库的 Marshal API.

Marshal 返回参数 v 的 JSON 编码结果,此方法适应于 json/encoding 库中的 Marshal API, 更多信息请参考 https://godoc.org/encoding/json#Marshal

func MarshalIndent

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

MarshalIndent 与 json.MarshalIndent 功能相同。

func NewDecoder

func NewDecoder(reader io.Reader) *json.Decoder

NewDecoder 适应于 json/stream 的 NewDecoder API。

NewDecoder 函数返回一个从 r 读取数据的新解码器。

返回的不是一个 json/encoding 包中的 Decoder,而是一个自定义的 Decoder。 有关更多信息,请参考 https://godoc.org/encoding/json#NewDecoder

func NewEncoder

func NewEncoder(writer io.Writer) *json.Encoder

NewEncoder 与 json.NewEncoder 功能相同

func Unmarshal

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

Unmarshal 适应 json/encoding 的 Unmarshal API

Unmarshal 解析 JSON 编码的数据,并将结果存储在 v 指向的值中。 有关更多信息,请参考 https://godoc.org/encoding/json#Unmarshal

func UnmarshalUseNumber

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

UnmarshalUseNumber 使用数字选项将json数据字节解码到目标接口。

func Valid

func Valid(data []byte) bool

Valid 报告 data 是否为有效的 JSON 编码。

Types

type RawMessage

type RawMessage = json.RawMessage

RawMessage 是一个原始编码的 JSON 值。 它实现了 Marshaler 和 Unmarshaler 接口,可用于延迟 JSON 解码或预计算 JSON 编码。

Jump to

Keyboard shortcuts

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