json

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 4 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBytes

func FromBytes(bytes []byte, target interface{}) error

FromBytes 字节数组转对象

func FromJson

func FromJson(jsonStr string, target interface{}) error

FromJson json 字符串转对象

func RegisterFuzzyDecoders added in v0.0.3

func RegisterFuzzyDecoders()

RegisterFuzzyDecoders 处理字符串和数字自动转换

func RegisterTimeAsInt64Codec

func RegisterTimeAsInt64Codec(precision time.Duration)

RegisterTimeAsInt64Codec 注册时间类型为 int64

func ToBytes

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

ToBytes 对象转字节数组

func ToJson

func ToJson(data interface{}) (string, error)

ToJson 对象转 json 字符串

Types

type Any

type Any = jsoniter.Any

Any alias to jsoniter.Any

func GetNodeFromBytes

func GetNodeFromBytes(byt []byte, path interface{}) Any

GetNodeFromBytes 通过路径,快速从字节数组解析数据

func GetNodeFromString

func GetNodeFromString(jsonStr string, path interface{}) Any

GetNodeFromString 通过路径,快速从json字符串解析数据

type Decoder

type Decoder = jsoniter.Decoder

Decoder alias to jsoniter.Decoder

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder jsoniter.NewDecoder

type DelayJsoniter

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

DelayJsoniter 通过重写 string() 方法来延迟执行json序列化

func ToJsonDelay

func ToJsonDelay(data interface{}) *DelayJsoniter

ToJsonDelay 对象转 json 字符串,在调用 String() 方法时才会执行转换方法

func (*DelayJsoniter) String

func (d *DelayJsoniter) String() string

String 返回json字符串,如果失败则返回error信息

type Encoder

type Encoder = jsoniter.Encoder

Encoder alias to jsoniter.Encoder

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder jsoniter.NewEncoder

Jump to

Keyboard shortcuts

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